Skip to content

fix(content-disposition): allow empty filename without throwing error #466

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ItayLeon-Max
Copy link

Description:
This pull request fixes an issue in the @tinyhttp/content-disposition package where parsing a Content-Disposition header with an empty filename would incorrectly throw an invalid extended field value error.
Now, if the filename* parameter value is empty, it will be properly handled and parsed as an empty string ('') instead of causing an exception.
This behavior aligns with the expectation that an empty filename is valid per the relevant RFC standards.

Changes:
• Updated parse function to treat empty extended parameters correctly.
• Adjusted decodefield to return an empty string when input is empty.
• Added safeguard for handling empty filename* values without throwing.

Impact:
This change ensures better compliance with the Content-Disposition specification and prevents runtime errors when dealing with empty filenames.

ItayLeon-Max and others added 2 commits April 29, 2025 06:04
refactor(content-disposition): simplify empty filename handling

Co-authored-by: v1rtl <hi@v1rtl.site>
@ItayLeon-Max
Copy link
Author

Hope you’re doing well!
Just wanted to ask if everything looks good now and if we can go ahead and merge the pull request.
Please let me know if there’s anything else you’d like me to adjust or review.

Thanks again for your guidance!

@ItayLeon-Max ItayLeon-Max force-pushed the fix-empty-filename-content-disposition branch from e14b703 to 24b588c Compare April 29, 2025 17:25
@ItayLeon-Max ItayLeon-Max force-pushed the fix-empty-filename-content-disposition branch from 24b588c to ce7eb85 Compare April 29, 2025 17:26
@@ -22,6 +22,7 @@
},
"dependencies": {
"@tinyhttp/accepts": "workspace:*",
"@tinyhttp/req": "workspace:^",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you add the package to itself?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants