Skip to content

Commit

Permalink
Improve LEGACY ambiguous path example
Browse files Browse the repository at this point in the history
  • Loading branch information
joakime committed Feb 6, 2025
1 parent 7ac26ba commit 7f5c617
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static Server newServer(int port)
Server server = new Server();

HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setUriCompliance(UriCompliance.UNSAFE);
httpConfig.setUriCompliance(UriCompliance.LEGACY);

HttpConnectionFactory httpConnectionFactory = new HttpConnectionFactory(httpConfig);
ServerConnector connector = new ServerConnector(server, httpConnectionFactory);
Expand All @@ -44,10 +44,12 @@ public static Server newServer(int port)

ServletContextHandler context = new ServletContextHandler();
context.setContextPath("/");
// Allow ServletContext to accept ambiguous uris.
context.getServletHandler().setDecodeAmbiguousURIs(true);
context.addServlet(AmbiguousPathServlet.class, "/*");

server.setHandler(context);
server.setDumpAfterStart(true);
return server;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public void stopServer()

@ParameterizedTest
@ValueSource(strings = {
"/git/branch/fix%2Frefactor"
"/git/branch/fix%2Frefactor",
"/git/branch/fix//refactor"
})
public void testAmbiguousPathSeparator(String path) throws IOException
{
Expand Down

0 comments on commit 7f5c617

Please sign in to comment.