-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HttpServletResponse.encodeURL not working for URLs starting with ../ #7615
Comments
I haven't replicated this yet, but this issue should also be impacting |
I have been able to replicate easily with this test case... The |
Opened PR #7616 with a fix. |
+ use presence of scheme to gate parsing as HttpURI Signed-off-by: Greg Wilkins <[email protected]>
+ use presence of scheme to gate parsing as HttpURI Signed-off-by: Greg Wilkins <[email protected]>
Closing, Merged PR #7763 |
Reopening as not yet merged to 10, 11 & 12! |
cherry-picked from 9c30caf Signed-off-by: Greg Wilkins <[email protected]>
fixed checkstyle Signed-off-by: Greg Wilkins <[email protected]>
* Fix #7615 encode relative URIs cherry-picked from 9c30caf Signed-off-by: Greg Wilkins <[email protected]> * Fix #7615 encode relative URIs fixed checkstyle Signed-off-by: Greg Wilkins <[email protected]>
Jetty version(s)
9.4.37 - 9.4.45
Java version/vendor
Java 1.8.0
OS type/version
Mac
Description
When doing HttpServletResponse.encodeURL("../foo/bar.jsp") when client has no session cookie so the URL should be rewritten as "../foo/bar.jsp;jsessionid=[sessionID]" the HttpURI.parse method responds with "Bad URI".
That is not a "Bad URI". Relative URLs with any number of ../ must be allowed.
How to reproduce?
Create a foo.jsp file in a foo-folder that just contains:
<%= response.encodeURL("../foo/bar.jsp") %>
Access the page http://[server]/foo/foo.jsp with a client that doesn't send cookies, or have no JSESSIONID cookie, like
curl http://[server]/foo/foo.jsp
This worked upto and including Jetty 9.4.36, but don't work with Jetty 9.4.37 and newer. So some update in 9.4.37 must have made this break.
I have 3rd party libraries that does this within servlets that I can't change, so it's a showstopper for me to upgrade to the latest version of Jetty.
The text was updated successfully, but these errors were encountered: