https://bz.apache.org/bugzilla/show_bug.cgi?id=63275
Bug ID: 63275
Summary: HttpServletRequest.getContextPath does not return an
URL encoded value when forwarding a request to a
multibyte context
Product: Tomcat 9
Version: 9.0.x
Hardware: PC
Status: NEW
Severity: major
Priority: P2
Component: Catalina
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: -----
I have prepared a setup which can be used to reproduce the scenario:
https://github.com/cbos/TomcatApplicationDispatcherBug
If you visit /tomcat-diagnostics東京/diagnostics it returns:
requestURI=/tomcat-diagnostics%E6%9D%B1%E4%BA%AC/diagnostics
requestURL=http://localhost:8080/tomcat-diagnostics%E6%9D%B1%E4%BA%AC/diagnostics
contextpath=/tomcat-diagnostics%E6%9D%B1%E4%BA%AC
servletpath=/diagnostics
When you visit /tomcat-diagnostics東京/crosscontext/diagnostics it returns:
requestURI=/tomcat-diagnostics%E6%9D%B1%E4%BA%AC/diagnostics
requestURL=http://localhost:8080/tomcat-diagnostics%E6%9D%B1%E4%BA%AC/diagnostics
contextpath=/tomcat-diagnostics??
servletpath=/diagnostics
Contextpath is decoded, instead of encoded.
According to the servletapi, getContextPath details:
https://tomcat.apache.org/tomcat-9.0-doc/servletapi/javax/servlet/http/HttpServletRequest.html#getContextPath--
"The container does not decode this string."
The bug for this is
org.apache.catalina.core.ApplicationDispatcher#doForward
Line 374: wrequest.setContextPath(context.getPath());
Should be:
wrequest.setContextPath(context.getEncodedPath());
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]