Constrain which encodings are supported by `response.text`.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 78
- Avg merge
- 8h 59m
- Merged PRs (30d)
- 24
Description
Originally opened by
@tomchristieon 2023-10-13 12:44:05 in encode/httpx
- Initially raised as discussion #2881
Currently when accessing response.text any installed codec may be loaded, depending on the Content-Type header of the response. This is problematic partly because not all codecs are text codecs. It also feels too open, as custom codecs might be installed with arbitrary behaviours.
May suggestion would be that we support the same set of encodings as the chromium browser... https://chromium.googlesource.com/chromium/chromium/+/refs/heads/trunk/chrome/browser/character_encoding.cc#36
We can effect this change by having a hardcoded set of supported codecs, here...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in httpx/_utils.py at the hardcoded codec set referenced by the issue, then compare it with Chromium’s supported encoding list. Trace how response.text resolves the Content-Type encoding and inspect the existing tests covering response text or codecs. Done means response.text is limited to the supported set and does not load arbitrary installed codecs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- Half a day
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100