You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2019/03/21 09:06:47 UTC

[Bug 63275] New: HttpServletRequest.getContextPath does not return an URL encoded value when forwarding a request to a multibyte context

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: dev@tomcat.apache.org
          Reporter: ceesbos@solcon.nl
  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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 63275] HttpServletRequest.getContextPath does not return an URL encoded value when forwarding a request to a multibyte context

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63275

Donald <dk...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dkwakkel@gmail.com

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 63275] HttpServletRequest.getContextPath does not return an URL encoded value when forwarding a request to a multibyte context

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63275

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #1 from Mark Thomas <ma...@apache.org> ---
Thanks for the report. I was able to reproduce this by modifying one of our
existing test cases.

Fixed in:
- master for 9.0.18 onwards
- 8.5.x for 8.5.40 onwards
- 7.0.x for 7.0.94 onwards

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 63275] HttpServletRequest.getContextPath does not return an URL encoded value when forwarding a request to a multibyte context

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63275

--- Comment #2 from Cees Bos <ce...@solcon.nl> ---
@Mark, thanks for the quick fix!

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 63275] HttpServletRequest.getContextPath does not return an URL encoded value when forwarding a request to a multibyte context

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63275

Cees Bos <ce...@solcon.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ceesbos@solcon.nl
                 OS|                            |All

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org