Add workaround for noncompliant Content-Disposition headers. #2153
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 inparse_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 iflen > 0
and the final character is;
, then prints a message at INFO level and decrementseop
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 😄