Skip to content
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

Add workaround for noncompliant Content-Disposition headers. #2153

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

neggles
Copy link

@neggles neggles commented Dec 10, 2023

Despite it not being allowed by RFC 6266, many servers send Content-Disposition headers with a trailing ;, including several major content distribution networks. Add a check for a trailing semicolon in parse_content_disposition() which will log a message at INFO level for each offending URL and ignore the ;.

Fixes #1118.

This probably isn't the best way to handle this, but the state machine code inside parse_content_disposition() is rather complicated so I elected to mess with it as little as possible. Code just checks if len > 0 and the final character is ;, then prints a message at INFO level and decrements eop by one so the remaining code will ignore it (credit to @mgrinzPlayer for the idea).

Happy to come at this from another direction if you'd prefer 😄

Despite it not being allowed by RFC 6266, many servers send
`Content-Disposition` headers with a trailing `;`, including several major
content distribution networks. Add a check for a trailing semicolon in
`parse_content_disposition()` which will log a message at INFO level
for each offending URL and ignore the `;`.
@fenopa
Copy link

fenopa commented Dec 10, 2023

Thanks for the PR, personally, I don't think that's something that needs to be logged at INFO level. I say debug level is better.

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.

Check the header “Content-Disposition” to determine the filename to store
2 participants