Merged branch 'jetty-9.4.x' into 'master'.

This commit is contained in:
Simone Bordet 2017-10-06 09:18:47 +02:00
commit 23bfdd625d
2 changed files with 23 additions and 15 deletions

View File

@ -707,7 +707,7 @@ public class Response implements HttpServletResponse
String path=_channel.getRequest().getRequestURI();
String parent=(path.endsWith("/"))?path:URIUtil.parentPath(path);
location=URIUtil.canonicalEncodedPath(URIUtil.addEncodedPaths(parent,location));
if (!location.startsWith("/"))
if (location!=null && !location.startsWith("/"))
buf.append('/');
}

View File

@ -18,20 +18,6 @@
package org.eclipse.jetty.server;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
@ -87,6 +73,20 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@RunWith(AdvancedRunner.class)
public class ResponseTest
{
@ -784,6 +784,14 @@ public class ResponseTest
}
}
@Test(expected = IllegalStateException.class)
public void testInvalidSendRedirect() throws Exception
{
// Request is /path/info, so we need 3 ".." for an invalid redirect.
Response response = getResponse();
response.sendRedirect("../../../invalid");
}
@Test
public void testSetBufferSizeAfterHavingWrittenContent() throws Exception
{