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

Limit which text codecs are supported. #2896

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

tomchristie
Copy link
Member

Closes #2892.

Constrains which text codecs are supported when accessing response.text.
(Uses the set currently supported by the Chromium browser.)

Initially prompted by behaviour in #2881 where a non-text codec "base64" was being loaded and causing an exception. The behaviour after this PR would be to fallback to utf-8 in that case, with safe character replacement. The result would be the base64 encoded string being returned as a string.

@tomchristie tomchristie added the enhancement New feature or request label Oct 19, 2023
@tomchristie tomchristie requested a review from a team October 19, 2023 09:49
httpx/_utils.py Outdated Show resolved Hide resolved
Comment on lines +34 to +35
# We're referencing them with the canonical name as used by the Python codecs.
# The alias given in the chromium source is included as a comment for comparison.
Copy link
Member Author

Choose a reason for hiding this comment

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

We're referencing these character sets with the canonical name as used by the Python codecs.

  • Will the canonical name for the codec be consistent across different Python implementations?
  • Should we instead just be including all the possible aliases explicitly?
  • What set of aliases does chromium support for these charset names?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Constrain which encodings are supported by response.text.
3 participants