httpx
httpx copied to clipboard
Constrain which encodings are supported by `response.text`.
trafficstars
- [x] 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...
https://github.com/encode/httpx/blob/e63b6594f2863b7c8274eb0991ebc6cad63661f7/httpx/_utils.py#L71-L79