test: cover malformed UTF-8 sequences in strings and keys - #1337
Open
VedantMadane wants to merge 3 commits into
Open
VedantMadane wants to merge 3 commits into
VedantMadane wants to merge 3 commits into
Conversation
Add regression coverage for truncated multi-byte sequences, invalid continuation bytes, overlong encodings, and bad lead bytes when deserializing into Value and String via from_slice (issue serde-rs#1185). Also reject invalid UTF-8 in object keys. Signed-off-by: Vedant Madane <6527493+VedantMadane@users.noreply.github.com>
Signed-off-by: Vedant Madane <6527493+VedantMadane@users.noreply.github.com>
\xC2\x00 is reported as a control character (0x00-0x1F) before UTF-8 validation, which failed nightly and Miri. Use \xC2\x7F instead so the case asserts the invalid-unicode diagnostic. Signed-off-by: Vedant Madane <6527493+VedantMadane@users.noreply.github.com>
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.
Summary
Adds focused regression tests for malformed UTF-8 inside JSON strings and object keys when deserializing via
from_sliceintoValueandString(issue #1185).Why
#1185 asks for stronger coverage of intentionally invalid UTF-8 after performance-oriented parsing changes. Existing coverage had a single
test_raw_invalid_utf8case; this expands that to truncated multi-byte sequences, invalid continuations, overlong encodings, bad lead bytes, and bad object keys.Tests
test_invalid_utf8_sequences_in_strings— 9 malformed payloads; assertsinvalid unicode code pointand thatValue/Stringdiagnostics matchtest_invalid_utf8_in_object_keys— rejects bad UTF-8 in map keysCompleteness
No production code stubs. Tests only; behavior is reject-with-error (existing correct path).
Fixes #1185