-
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
Unexpected encoding in request.getPathInfo() with Jetty 12 beta 0 #9444
Comments
Which ee level are you using when this happens? |
|
I suspect this is some fallout from the discussion at jakartaee/servlet#18 with Servlet 6.x |
So jakartaee/servlet@e1292f9 changes the text for
to
which seems to indicate that this has changed. But then there is
which I am not sure what it tries to say |
This section of the spec is a bit confusing. Bear with us. Until we get a definitive answer ... If you write Vaadin for multiple containers, be aware that this part of the spec says that the container can decide what to return here (regarding what's encoded or not). |
That sounds horrible I tested with https://github.com/Artur-/servlet-demo on Jetty 12 beta 0 and Tomcat 10.1.1 to request "hello world"
|
The ability to return encoded characters is intended for characters like %2f, which will normally be rejected. I think we should be decoding %20 as it is not ambiguous to do so. |
Ah we have messed up on %20 at least. It is meant to be decoded in getCanonicalPath, but sometimes it is not... because we are getting confused that space is not a safe character for a URI itself. However, it is perfectly safe to decode as it can be unambiguously re-encoded. Will need to review (again) before beta1 |
So our concept of a In our core request class, we just provide a The issue is when we come to the servlet API, the In our ee9 servlets, I believe we are further decoding the canonical URI (as we always have done) to the ambiguous form and trusting the URI violations reject bad requests. In ee10, we are just using the |
Added URIUtil.decodeSafePath for EE10, to allow for %2F and %25 to remain encoded in the servlet API. Fixed async dispatch to also safeDecode Updated tests to expect decoded space Apply suggestions from code review Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
@Artur- the fix is merged in head now. It would be great if you could test it before we do a beta1 release in the next few weeks. |
Is there a public snapshot I can test? |
It is currently building after the merge, but should be available from https://jenkins.webtide.net/blue/organizations/jenkins/jetty.project/detail/jetty-12.0.x/1083/artifacts |
We have nightly snapshot artifacts present at https://oss.sonatype.org/content/repositories/jetty-snapshots/ But that only occurs once a day, at midnight. |
Reopening, as this is now unsafe. Lets take a look at these scenarios with the current implementation from PR #9455
|
I'm introducing some test cases right now (which caught this case) |
* will use replacement characters instead of throwing an error.
getServletPath and getPathInfo will never return an encoded path segment. Instead, they will throw an IllegalArgumentException if they are called when there is a URI with violations.
getServletPath and getPathInfo will never return an encoded path segment. Instead, they will throw an IllegalArgumentException if they are called when there is a URI with violations.
getServletPath and getPathInfo will never return an encoded path segment. Instead, they will throw an IllegalArgumentException if they are called when there is a URI with violations.
getServletPath and getPathInfo will never return an encoded path segment. Instead, they will throw an IllegalArgumentException if they are called when there is a URI with violations.
getServletPath and getPathInfo will never return an encoded path segment. Instead, they will throw an IllegalArgumentException if they are called when there is a URI with violations.
getServletPath and getPathInfo will never return an encoded path segment. Instead, they will throw an IllegalArgumentException if they are called when there is a URI with violations.
Optionally throw on decode of ambiguous URIs
Optionally throw on decode of ambiguous URIs
I re-ran our tests today with the lastest Jetty 12 snapshot and it seems all tests pass except one that hits Looks like the test registers a route using the path
which then gets encoded into
and when the URL (http://localhost:8888/context-path/special%20%C3%A5%C3%A4%C3%B6%20$%2520'%C2%B4%60) is opened, the response is
|
What is |
note that the 12.0.0.beta0 doesn't have the latest decoding fixes on |
It is run using
as
together with
|
Was there any conclusion for this? It seems like 12 beta3 works like Jetty 11 except it disallows using an encoded |
@artur, By default we are not allowing %25 in a URI, as it can cause problems if that decoded string is passed to other APIs that do not know that the % is already decoded and thus try to decode it again. However, we have a violation mode AMBIGUOUS_PATH_ENCODING, that can be allowed. So a server can be configured to allows %25. |
Do I understand correctly that the consequence of this is that you cannot (by default) load a file with a name that contains then a request to
If I manually URI encode it and instead request
|
There are a lot of gotchas when relying on the Chrome location bar encode URLs properly.
You really shouldn't rely on that Chrome behavior. Now, the other URL you posted with This rule can be configured, btw. |
Closing this as I believe we are now doing as best we can. Please reopen if there are more problems. |
Jetty version(s)
12.0.0.beta0
Java version/vendor
openjdk version "19.0.1" 2022-10-18
OS type/version
mac os
Description
When requesting a URL like
http://localhost:8888/view/VAADIN/dynamic/resource/5/4a2dc788-7f04-43e4-8471-70d713d6d001/file%20name
with a servlet mapping of
/view/*
thenrequest.getPathInfo()
inJetty < 12 returns
"/VAADIN/dynamic/resource/5/4a2dc788-7f04-43e4-8471-70d713d6d001/file name"
whileJetty 12 returns
"/VAADIN/dynamic/resource/5/4a2dc788-7f04-43e4-8471-70d713d6d001/file%20name"
Is this an intentional change in some spec or accidental?
This breaks handling of resources like "file name" in Vaadin when run in 12 beta0 as Vaadin assumes the path info is decoded and then encodes it to match with a stored, encoded value.
The text was updated successfully, but these errors were encountered: