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

Parsing the content-disposition header with additional filename* parameter #429

Closed
starrify opened this issue Mar 9, 2024 · 0 comments · Fixed by #430
Closed

Parsing the content-disposition header with additional filename* parameter #429

starrify opened this issue Mar 9, 2024 · 0 comments · Fixed by #430

Comments

@starrify
Copy link
Contributor

starrify commented Mar 9, 2024

Overview

As per RFC 6266, a content-disposition header may include a filename* parameter for suggesting a file name with extended (non-ISO-8859-1) encoding.

axel doesn't seem to handle that properly which might be considered an issue.

Examples of this format

Here is one example given in RFC 6266:

     Content-Disposition: attachment;
                          filename="EURO rates";
                          filename*=utf-8''%e2%82%ac%20rates

Also here's an example from a real-world web server:
(the link points to an ISO image of Windows 11 Enterprise Edition)

$ URL="https://software-static.download.prss.microsoft.com/dbazure/888969d5-f34g-4e03-ac9d-1f9786c66749/22631.2428.231001-0608.23H2_NI_RELEASE_SVC_REFRESH_CLIENTENTERPRISEEVAL_OEMRET_x64FRE_en-us.iso"
$ curl -I -s "$URL" | grep -i '^content-disposition'
content-disposition: attachment; filename=22631.2428.231001-0608.23H2_NI_RELEASE_SVC_REFRESH_CLIENTENTERPRISEEVAL_OEMRET_x64FRE_en-us.iso; filename*=UTF-8''22631.2428.231001-0608.23H2_NI_RELEASE_SVC_REFRESH_CLIENTENTERPRISEEVAL_OEMRET_x64FRE_en-us.iso

Behavior of axel's, and of some other user agents

Here creates a dummy HTTP server for testing:

$ cat > tmp_payload <<- EOF
HTTP/1.1 200 OK
Content-Disposition: attachment; filename=foo; filename*=UTF-8''bar

foobar
EOF
$ socat -v TCP-LISTEN:8080,fork,reuseaddr,crlf SYSTEM:"cat tmp_payload"

Here's a list of observations per common user agent, when tested against the dummy server above:

user agent filename suggested
RFC 6266 preferred ("SHOULD") bar
RFC 6266 also okay foo
axel foo; filename_=UTF-8
curl -OJ foo
wget --content-disposition bar
Chrome / Firefox bar

(axel checked at revision 3f397e3 / 2.17.13)

starrify added a commit to starrify/axel that referenced this issue Mar 10, 2024
Fixes axel-download-accelerator#429.

This not mostly ideal (RFC 6266 prefers `filename*` if present) yet may
be considered good enough if we don't want to introdue UTF-8 decoding
here.
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 a pull request may close this issue.

1 participant