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

Headers.add fails with unicode #742

Closed
tko opened this issue Jun 17, 2015 · 2 comments
Closed

Headers.add fails with unicode #742

tko opened this issue Jun 17, 2015 · 2 comments

Comments

@tko
Copy link

tko commented Jun 17, 2015

# encoding: utf-8
from werkzeug.datastructures import Headers

headers = Headers()
headers.add('Content-Disposition', 'attachment', filename=u'åäö.html')
Traceback (most recent call last):
  File "test.py", line 5, in <module>
    headers.add('Content-Disposition', 'attachment', filename=u'åäö.html')
  File "/tmp/werkzeug/werkzeug/datastructures.py", line 1105, in add
    _value = _options_header_vkw(_value, kw)
  File "/tmp/werkzeug/werkzeug/datastructures.py", line 841, in _options_header_vkw
    for k, v in kw.items()))
  File "/tmp/werkzeug/werkzeug/http.py", line 214, in dump_options_header
    segments.append('%s=%s' % (key, quote_header_value(value)))
  File "/tmp/werkzeug/werkzeug/http.py", line 167, in quote_header_value
    value = str(value)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)
@untitaker
Copy link
Contributor

See pallets/flask#1286

@javabrett
Copy link

I am visiting this issue while making some commentary in the same area, but it seems that it should be closed/won't-fix, since non-ASCII and non-latin1 representations in HTTP headers can only be done in accordance with RFC 8187.

Please close.

@lepture lepture closed this as completed Nov 9, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants