-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fix #4012 encoding of content-disposition parameters #4031
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4031 +/- ##
==========================================
- Coverage 97.54% 97.53% -0.02%
==========================================
Files 43 43
Lines 8809 8798 -11
Branches 1415 1414 -1
==========================================
- Hits 8593 8581 -12
- Misses 101 103 +2
+ Partials 115 114 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@kxepal would you review? |
f886860
to
781b507
Compare
aiohttp/helpers.py
Outdated
qval = quote(val, '') if quote_fields else val | ||
lparams.append((key, '"%s"' % qval)) | ||
if key == 'filename': | ||
lparams.append(('filename*', "utf-8''" + qval)) |
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.
I'm not sure this is correct. filename*
must be added if filename
is not ASCII-only per RFC 6266, appendix D. The logic is supposed to be roughly https://github.com/cherrypy/cherrypy/pull/1851/files#diff-9d544371f1a0e2079e68ac3cca04bc6cd1ccaf92797f378b285f307871b8d6f0R32-R53. Note that NFKC is supposed to be used for normalization.
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.
Looking closer, it seems you may be right about the newer RFC...
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.
Hi. As this is the payload and not http Content-Disposition header, filename*
can not be used. I believe your link was about the http header.
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.
Ah, then I misread what you're doing here.
This comment has been minimized.
This comment has been minimized.
I rebased the commit on top of current master. I do not see the macos failure related to this PR. What is the CLA message? The link says
|
Please ignore the CLA, I've switched it off back -- and forever. |
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.
LGTM.
Thank you!
I'd like to get an additional review from aiohttp team, otherwise I'll merge this PR in a week.
It will be a part of aiohttp 3.8
Posting form data with field names containing "[]" were not recognized by other multipart/form-data parsers. The percent-encoding is only to be used on the filename parameter that follows how of a "file:" URI may be encoded according to RFC7578.
Thanks! |
💔 Backport was not successfulThe PR was attempted backported to the following branches:
|
…s#4031) Posting form data with field names containing "[]" were not recognized by other multipart/form-data parsers. The percent-encoding is only to be used on the filename parameter that follows how of a "file:" URI may be encoded according to RFC7578.
…s#4031) Posting form data with field names containing "[]" were not recognized by other multipart/form-data parsers. The percent-encoding is only to be used on the filename parameter that follows how of a "file:" URI may be encoded according to RFC7578.
Posting form data with field names containing "[]" were not recognized by other multipart/form-data parsers. The percent-encoding is only to be used on the filename parameter that follows how of a "file:" URI may be encoded according to RFC7578.
Backport to 3.8: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply aa11d78 on top of patchback/backports/3.8/aa11d78356e243be985f1d2a30f733d95417cf08/pr-4031 Backporting merged PR #4031 into master
🤖 @patchback |
aiohttp now percent-encodes filenames, causing a test to fail. aio-libs/aiohttp#4031
Posting form data with field names containing "[]" were not recognized
by other multipart/form-data parsers. The percent-encoding is only to
be used on the filename parameter that follows how of a "file:" URI
may be encoded according to RFC7578.
What do these changes do?
Only encode content-disposition filename parameter using percent-encoding.
Other parameters are encoded to quoted-string or RFC2231 extended parameter
value.
Are there changes in behavior for the user?
I do not know if there are some implementations that depend on the wrong encoding.
Related issue number
Related to #4012.
Checklist
CONTRIBUTORS.txt
CHANGES
folder<issue_id>.<type>
for example (588.bugfix)issue_id
change it to the pr id after creating the pr.feature
: Signifying a new feature..bugfix
: Signifying a bug fix..doc
: Signifying a documentation improvement..removal
: Signifying a deprecation or removal of public API..misc
: A ticket has been closed, but it is not of interest to users.