Skip to content

Commit 018647d

Browse files
committedSep 25, 2024·
Added test for #11298
1 parent 18b9782 commit 018647d

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed
 

‎jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/ComplianceViolations2616Test.java

+24-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import jakarta.servlet.http.HttpServletResponse;
3333
import org.eclipse.jetty.http.ComplianceViolation;
3434
import org.eclipse.jetty.http.HttpCompliance;
35+
import org.eclipse.jetty.http.UriCompliance;
3536
import org.eclipse.jetty.server.HttpConfiguration;
3637
import org.eclipse.jetty.server.HttpConnectionFactory;
3738
import org.eclipse.jetty.server.LocalConnector;
@@ -87,8 +88,8 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se
8788
{
8889
resp.setContentType("text/plain");
8990
PrintWriter out = resp.getWriter();
90-
List<String> headerNames = new ArrayList<>();
91-
headerNames.addAll(Collections.list(req.getHeaderNames()));
91+
out.printf("%s %s%s%s\n", req.getMethod(), req.getContextPath(), req.getServletPath(), req.getPathInfo());
92+
List<String> headerNames = new ArrayList<>(Collections.list(req.getHeaderNames()));
9293
Collections.sort(headerNames);
9394
for (String name : headerNames)
9495
{
@@ -183,4 +184,25 @@ public void testFoldedHeader() throws Exception
183184
assertThat("Response headers", response, containsString("X-Http-Violation-0: Line Folding not supported"));
184185
assertThat("Response body", response, containsString("[Name] = [Some Value]"));
185186
}
187+
188+
@Test
189+
public void testAmbiguousSlash() throws Exception
190+
{
191+
String request = """
192+
GET /dump/foo//bar HTTP/1.1\r
193+
Host: local\r
194+
Connection: close\r
195+
\r
196+
""";
197+
198+
String response = connector.getResponse(request);
199+
assertThat(response, containsString("HTTP/1.1 400 Bad"));
200+
201+
connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration().setUriCompliance(UriCompliance.RFC3986.with("test", UriCompliance.Violation.AMBIGUOUS_EMPTY_SEGMENT));
202+
server.getContainedBeans(ServletHandler.class).stream().findFirst().get().setDecodeAmbiguousURIs(true);
203+
204+
response = connector.getResponse(request);
205+
assertThat(response, containsString("HTTP/1.1 200 OK"));
206+
assertThat(response, containsString("GET /dump/foo//bar"));
207+
}
186208
}

0 commit comments

Comments
 (0)
Please sign in to comment.