Skip to content

Proper enconding of Content-Dispisition filename#71

Merged
dg merged 1 commit into
nette:masterfrom
foxycode:master
Mar 23, 2015
Merged

Proper enconding of Content-Dispisition filename#71
dg merged 1 commit into
nette:masterfrom
foxycode:master

Conversation

@foxycode
Copy link
Copy Markdown
Contributor

According to RFC 5987 Content-Disposition filename should not contain non-US-ASCII characters.

Proper way to encode filename is this:
"filename*=utf-8''%C5%BElu%C5%A5ou%C4%8Dk%C3%BD%20k%C5%AF%C5%88.txt".

Unfortunately, RFC 5987 is not supported by all browsers, so for compatibility reasons, filename should be sent like this:
"filename=žluťoučký kůň.txt; filename*=utf-8''%C5%BElu%C5%A5ou%C4%8Dk%C3%BD%20k%C5%AF%C5%88.txt".

Some discussion about this is here: http://stackoverflow.com/questions/93551/how-to-encode-the-filename-parameter-of-content-disposition-header-in-http

@fprochazka
Copy link
Copy Markdown
Contributor

Great work 👍

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

decode or encode?

@foxycode
Copy link
Copy Markdown
Contributor Author

@dg Of course encode :-) Updated.

@dg
Copy link
Copy Markdown
Member

dg commented Mar 18, 2015

Should it be "filename=žluťoučký kůň.txt; filename*=utf-8''%C5%B... or "filename=zlutoucky kun.txt; filename*=utf-8''%C5%B...? (i.e. in ASCII)

@foxycode
Copy link
Copy Markdown
Contributor Author

@dg I tried current approach with "filename="žluťoučký kůň.txt"; filename*=utf-8''%C5%B... and it works great in FF 36, Chrome 41 and IE 11. According linked discussion, browsers without RFC 5987 support should ignore second filename part and thus use same filename which nette sent before.

@dg
Copy link
Copy Markdown
Member

dg commented Mar 23, 2015

Can you add prefix FileResponse: in commit message?

@dg
Copy link
Copy Markdown
Member

dg commented Mar 23, 2015

…ld not contain non-US-ASCII characters. Proper way to encode filename is this: "filename*=utf-8''%C5%BElu%C5%A5ou%C4%8Dk%C3%BD%20k%C5%AF%C5%88.txt". Unfortunately, RFC 5987 is not supported by all browsers, so for compatibility reasons, filename should be sent like this: "filename=žluťoučký kůň.txt; filename*=utf-8''%C5%BElu%C5%A5ou%C4%8Dk%C3%BD%20k%C5%AF%C5%88.txt".
@foxycode
Copy link
Copy Markdown
Contributor Author

Prefix added, I'll look to your link more tomorrow, but according to what I've read my solution should work just fine.

dg added a commit that referenced this pull request Mar 23, 2015
Proper enconding of Content-Dispisition filename
@dg dg merged commit be8e35b into nette:master Mar 23, 2015
@dg
Copy link
Copy Markdown
Member

dg commented Mar 23, 2015

Thanks!

@foxycode
Copy link
Copy Markdown
Contributor Author

@dg When you plan next release (2.3.2)?

@dg
Copy link
Copy Markdown
Member

dg commented Mar 25, 2015

Soon

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.

3 participants