Skip to content

Commit

Permalink
Issue #7160- Add AMBIGUOUS_PATH_ENCODING to default UriCompliance mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlan-roberts authored and joakime committed Feb 24, 2022
1 parent 94211f9 commit 051af89
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ public String getDescription()
* additional violations to avoid most ambiguous URIs.
* This mode does allow {@link Violation#AMBIGUOUS_PATH_SEPARATOR}, but disallows all out {@link Violation}s.
*/
public static final UriCompliance DEFAULT = new UriCompliance("DEFAULT", of(Violation.AMBIGUOUS_PATH_SEPARATOR));
public static final UriCompliance DEFAULT = new UriCompliance("DEFAULT",
of(Violation.AMBIGUOUS_PATH_SEPARATOR,
Violation.AMBIGUOUS_PATH_ENCODING));

/**
* LEGACY compliance mode that models Jetty-9.4 behavior by allowing {@link Violation#AMBIGUOUS_PATH_SEGMENT},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1871,7 +1871,7 @@ public void testAmbiguousEncoding() throws Exception
"Host: whatever\r\n" +
"\r\n";
_connector.getBean(HttpConnectionFactory.class).getHttpConfiguration().setUriCompliance(UriCompliance.DEFAULT);
assertThat(_connector.getResponse(request), startsWith("HTTP/1.1 400"));
assertThat(_connector.getResponse(request), startsWith("HTTP/1.1 200"));
_connector.getBean(HttpConnectionFactory.class).getHttpConfiguration().setUriCompliance(UriCompliance.LEGACY);
assertThat(_connector.getResponse(request), startsWith("HTTP/1.1 200"));
_connector.getBean(HttpConnectionFactory.class).getHttpConfiguration().setUriCompliance(UriCompliance.RFC3986);
Expand Down Expand Up @@ -1902,6 +1902,11 @@ public void testAmbiguousDoubleSlash() throws Exception
assertThat(_connector.getResponse(request), startsWith("HTTP/1.1 200"));
_connector.getBean(HttpConnectionFactory.class).getHttpConfiguration().setUriCompliance(UriCompliance.UNSAFE);
assertThat(_connector.getResponse(request), startsWith("HTTP/1.1 200"));

UriCompliance custom = new UriCompliance("Custom", EnumSet.complementOf(
EnumSet.of(UriCompliance.Violation.AMBIGUOUS_PATH_ENCODING)));
_connector.getBean(HttpConnectionFactory.class).getHttpConfiguration().setUriCompliance(custom);
assertThat(_connector.getResponse(request), startsWith("HTTP/1.1 400"));
}

@Test
Expand Down

0 comments on commit 051af89

Please sign in to comment.