Skip to content

Fix Unicode literals in textual bytes and fixed values - #312

Open
Shubham-Padkonde wants to merge 1 commit into
linkedin:masterfrom
Shubham-Padkonde:fix/textual-byte-codepoints
Open

Shubham-Padkonde wants to merge 1 commit into
linkedin:masterfrom
Shubham-Padkonde:fix/textual-byte-codepoints

Conversation

@Shubham-Padkonde

@Shubham-Padkonde Shubham-Padkonde commented Oct 2, 2026 •

Copy link
Copy Markdown

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=1 and git diff --check pass. go vet ./... reports pre-existing unreachable code in examples/soe/main.go:52; the changed package passes go vet ..

Reference: https://avro.apache.org/docs/1.12.0/specification/#json-encoding (JSON uses the field-default encoding for non-union values).

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.

textual format does not correctly decode unicode strings

1 participant