Repository navigation
Fix Unicode literals in textual bytes and fixed values - #312
Open
Shubham-Padkonde wants to merge 1 commit into
Open
Shubham-Padkonde wants to merge 1 commit into
Shubham-Padkonde wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #192. Avro's JSON representation maps code points 0–255 to byte values, but literal non-ASCII characters are currently copied as UTF-8 bytes. For example, "ÿ" yields two bytes while "\u00ff" yields one; a normal JSON round-trip can therefore change the decoded data.
Decode literal UTF-8 into byte-valued code points, and validate the entire escaped code point instead of silently discarding its high two hex digits. Reject malformed UTF-8 and code points outside the byte range. The shared decoder also fixes fixed values containing these literals.
Tests cover all 256 byte values through encoding/json, escaped/literal fixed-value equivalence, malformed hex/UTF-8, out-of-range code points, and unread trailing input. The added byte tests fail before the change.
go test ./... -count=1andgit diff --checkpass.go vet ./...reports pre-existing unreachable code in examples/soe/main.go:52; the changed package passesgo vet ..Reference: https://avro.apache.org/docs/1.12.0/specification/#json-encoding (JSON uses the field-default encoding for non-union values).