Skip to content

404 error with double slash in context path [SPR-10467] #15100

@spring-projects-issues

Description

@spring-projects-issues

Peter De Wachter opened SPR-10467 and commented

I have a webapp configured for the path /test, a servlet-mapping in web.xml for the url-pattern '/*' to a DispatcherServlet and a @RequestMapping "/foo/bar". The container is Tomcat 7.

With this setup the following request succeeds:
http://host/test/foo/bar => OK

And also if you add double slashes to the request mapping part:
http://host/test//foo//bar => OK

But if you use a double slash in the context path, it fails:
http://host//test/foo/bar => 404

This is a very minor issue, but it can be annoying as scripts often construct URLs in an ad-hoc manner and end up with doubled slashes.

The reason is that UrlPathHelper#getPathWithinApplication gets confused by the double slash. getContextPath returns "/test", getRequestUri returns "//test/foo/bar" and as a result getRemainingPart fails.

I suspect the fix is to make decodeAndCleanUriString replace "//" by "/".


Affects: 3.2.2

Issue Links:

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: duplicateA duplicate of another issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions