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

aiohttp is too strict when detecting charset in content_types #2197

Closed
hynek opened this issue Aug 14, 2017 · 5 comments
Closed

aiohttp is too strict when detecting charset in content_types #2197

hynek opened this issue Aug 14, 2017 · 5 comments
Labels
Milestone

Comments

@hynek
Copy link
Contributor

hynek commented Aug 14, 2017

Long story short

The presence of a ; in a content type does not mean that it contains a charset.

Expected behaviour

Only complain about charsets if there's a charset in content_type.

Actual behaviour

text/plain; version=0.0.4 will raise an ValueError: charset must not be in content_type argument.

The problem are these lines:

if content_type is not None and ";" in content_type:
raise ValueError("charset must not be in content_type "
"argument")

aiohttp just checks for a semicolon instead for the actual word charset.

Steps to reproduce

>>> from aiohttp.web import Response

>>> Response(text="hello", content_type="text/plain; version=0.0.4", charset="utf-8")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/hynek/.virtualenvs/prometheus_async/lib/python3.6/site-packages/aiohttp/web_response.py", line 451, in __init__
    raise ValueError("charset must not be in content_type "
ValueError: charset must not be in content_type argument
charset must not be in content_type argument
@asvetlov
Copy link
Member

Makes sense.

@argaen
Copy link
Member

argaen commented Sep 7, 2017

Is anyone working on this? If not I can go for it (and maybe we can add it in the next release)

@asvetlov
Copy link
Member

asvetlov commented Sep 7, 2017

Please do.

@asvetlov
Copy link
Member

asvetlov commented Feb 9, 2018

Fixed by #2493

@asvetlov asvetlov closed this as completed Feb 9, 2018
@lock
Copy link

lock bot commented Oct 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs.
If you feel like there's important points made in this discussion, please include those exceprts into that [new issue].
[new issue]: https://github.com/aio-libs/aiohttp/issues/new

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants