Skip to content

Fix bug in JSON base64 encoding - #217

Merged
jcrist merged 1 commit into
mainfrom
fix-json-encode-binary
Nov 29, 2022
Merged

Fix bug in JSON base64 encoding#217
jcrist merged 1 commit into
mainfrom
fix-json-encode-binary

Conversation

@jcrist

@jcrist jcrist commented Nov 29, 2022

Copy link
Copy Markdown
Member

Previously there was a bug in the base64 encoding implementation used by msgspec.json for encoding bytes/bytearray/memoryview objects. This bug only appeared for bytes with values outside the range 0 <= x <= 127, which weren't caught by the existing tests.

To remedy this we:

  • fix the bug
  • augment the existing test suite to cover this situation
  • add some fuzz testing for the base64 encoding code

Fixes #215.

Previously there was a bug in the base64 encoding implementation used by
`msgspec.json` for encoding `bytes`/`bytearray`/`memoryview` objects.
This bug only appeared for bytes with values outside the range 0 <= x <=
127, which weren't caught by the existing tests.

To remedy this we:
- fix the bug
- augment the existing test suite to cover this situation
- add some fuzz testing for the base64 encoding code
@jcrist
jcrist force-pushed the fix-json-encode-binary branch from 1332f3e to 8b62a73 Compare November 29, 2022 04:48
@jcrist
jcrist merged commit d12140b into main Nov 29, 2022
@jcrist
jcrist deleted the fix-json-encode-binary branch November 29, 2022 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON encoding corrupts binary data

1 participant