-
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
Simplified QuotedStringTokenizer #9729
Conversation
Now implements a simple subset of `quoted-string` from RFC9110
Now implements a simple subset of `quoted-string` from RFC9110
…lify-QuotedStringTokenizer
This could be a little bit controversial as it is used in a lot of places and I've just removed the ability to quote anything special. i.e. there is now no support of "\uab12" style unicode escapes, nor "\t" tabs etc. Also there is no leniency for browsers that do not quote "". There was no spec for any of those. We now just implement RFC9110 quoted-string. thoughts? |
@@ -677,7 +674,7 @@ public void testPartWithBackSlashInFileName() throws Exception | |||
|
|||
String contents = """ | |||
--AaB03x\r | |||
content-disposition: form-data; name="stuff"; filename="Taken on Aug 22 \\ 2012.jpg"\r | |||
content-disposition: form-data; name="stuff"; filename="Taken on Aug 22 \\\\ 2012.jpg"\r |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels weird. Why there are now 2 backslashes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we used to forgive browsers for not properly escaping "" in filenames. Now we are going to insist they quote them correctly.
Could be a bad idea. @joakime can you do some tests on windows to see how "" is treated by current browsers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted. But there is no good solution. See comments below.
jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/QuotedStringTokenizer.java
Outdated
Show resolved
Hide resolved
@gregw FTR maybe create another class with stricter behavior and keep the old one around. |
After feedback from Simone, I'm going to:
@joakime Can you gather some stats from users about filenames passed to multi-part. Specifically do any still have non escaped "" in the filename? Or do any actually use the '\t' or '\n' style escapes. Putting this back to draft for now. |
…lify-QuotedStringTokenizer # Conflicts: # jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/HttpField.java
…lify-QuotedStringTokenizer # Conflicts: # jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/HttpField.java
@joakime the tests that you added for multipart file uploads answers the question "do browser correctly quote ''" as we have tests for msie and edge that expect to handle Content-Disposition: form-data; name="file"; filename="C:\Users\joakim\Pictures\jetty-avatar-256.png" So I think we do need a mode that doesn't treat '' as an escape. Do you you know how such browsers escape characters if they don't treat '' specially? Specifically, what do they do if there is a |
I think we may need to implement rfc8187 which replaces rfc5987 which is suggest as per We will still need a mode that correctly handles the none escaped '' in filenames, but we should look for filename* for the filename we actually use. |
@joakime can you gather the raw browser-capture data (like you did for jetty-core/jetty-http/src/test/resources/multipart) for multi part requests that have filenames containing non ASCII characters (eg I'm very interested to see if RFC8187 is widely supported. |
Just doing a test with Chrome Version 113.0.5672.63 (Official Build) (64-bit) A file called
I can't tell what character that is instead of the euro. It pastes into characters app as \u0000 and into intellij as \u0080, which is the unicode control character??? A file called
So no RFC 8187 here... but also no usage of slosh escaping rather % escaping. Except the very same browser uploads
So they are not consistent! No idea what we should do? |
I can, but it'll have to wait till I get back. |
added javadoc fixed quoteIfNeeded test
@sbordet I've pushed some javadoc |
…lify-QuotedStringTokenizer
jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/QuotedStringTokenizer.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/QuotedStringTokenizer.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/QuotedStringTokenizer.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/QuotedStringTokenizer.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/QuotedStringTokenizer.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/QuotedStringTokenizerRfc9110.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/QuotedStringTokenizer.java
Show resolved
Hide resolved
jetty-core/jetty-http/src/test/java/org/eclipse/jetty/http/MultiPartFormDataTest.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/HttpField.java
Outdated
Show resolved
Hide resolved
...ecurity/src/main/java/org/eclipse/jetty/ee9/security/authentication/DigestAuthenticator.java
Outdated
Show resolved
Hide resolved
…lify-QuotedStringTokenizer
Now implements a simple subset of
quoted-string
from RFC9110