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

Allow for autodection of encoding for scalar values #5486

Open
wants to merge 4 commits into
base: master
from

Conversation

@blenq
Copy link

blenq commented Jun 10, 2020

Since JSON RFC 7158 (and also in 7159 and 8259) scalar values are also valid JSON texts. The json decoder from the Python standard libs also accepts such scalar values.

The JSON Unicode detection algorithm in "requests" assumes that the first two characters are always ASCII. That is not true anymore.
Therefore the current detection fails in at least these two edge cases

  • A single digit in UTF-16 encoding
  • A quoted string with the first character having a Unicode value higher than 255 in UTF-16 encoding

Also autodetection by chardet returns the wrong encoding.

This change detects the encoding in case of those two edge cases.

blenq added 4 commits Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant
You can’t perform that action at this time.