-
-
Notifications
You must be signed in to change notification settings - Fork 11.4k
fix(Content-Disposition): properly parse and decode filename from header #7159
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
base: v1.x
Are you sure you want to change the base?
fix(Content-Disposition): properly parse and decode filename from header #7159
Conversation
|
Hi maintainers 👋 This PR isolates the ✅ Handles both quoted and UTF-8 encoded ( Thanks for reviewing! 🙏 |
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.
It's unclear why you're regressing the code to use var, using arrays instead of a hash object, and matching for both regular expressions at once. The only purpose of parseHeaders is to parse headers into an object representation. There shouldn't be any high-level manipulations that could lose or corrupt the original headers. For high-level header manipulations, the AxiosHeaders class was introduced. Similar logic can be written in AxiosHeaders.getAttachment() method, but definitely not in the low-level parseHeaders utility. This way, the user will be able to operate with the original headers and obtain the decoded file name if needed.
|
Thanks for the review, @DigitalBrainJS 🙏 You're absolutely right — the Once I refactor it accordingly, I’ll update the PR for re-review. |
…Disposition header according to RFC5987
|
All Node.js tests pass — 224/224 passing. This PR fixes filename extraction from the Summary of changes
Results
**Ready for review ** |
Summary
Fixes filename extraction from the
Content-Dispositionheader by supporting both quoted and UTF-8 encoded (filename*) formats according to RFC5987.Changes
lib/helpers/parseHeaders.jsto correctly parse and decode bothfilenameandfilename*values.test/unit/helpers/parseHeaders.spec.js.Testing
npm test).Content-Disposition: attachment; filename="test.txt"Content-Disposition: attachment; filename*=UTF-8''résumé.pdfNotes
should support max content lengthis unrelated and can be ignored.Fixes #7142