test: prove Modified UTF-8 overlong NUL (0xC0 0x80) is rejected as OK…#42
Merged
test: prove Modified UTF-8 overlong NUL (0xC0 0x80) is rejected as OK…#42
Conversation
…J_ERROR_BAD_STRING Add test_utf8_overlong_nul_c0_80 which mathematically proves that the two-byte sequence 0xC0 0x80 — the "Modified UTF-8" overlong encoding of U+0000 — is caught by okj_validate_utf8_sequence and causes okj_parse to return OKJ_ERROR_BAD_STRING rather than accepting the sequence as valid or treating it as a premature string terminator. Proof embedded in the test comment: b0 = 0xC0 (192) ASCII gate: 0xC0 <= 0x7F => 192 <= 127 => FALSE 2-byte gate: 0xC0 >= 0xC2 => 192 >= 194 => FALSE (0xC0 and 0xC1 are deliberately excluded from [0xC2, 0xDF] per RFC 3629 §3) All remaining branch predicates also fail for b0 = 0xC0. Fall-through return 0U -> OKJ_ERROR_BAD_STRING. https://claude.ai/code/session_01HHohyZBhqxpWqruAGoeDtZ
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.
…J_ERROR_BAD_STRING
Add test_utf8_overlong_nul_c0_80 which mathematically proves that the two-byte sequence 0xC0 0x80 — the "Modified UTF-8" overlong encoding of U+0000 — is caught by okj_validate_utf8_sequence and causes okj_parse to return OKJ_ERROR_BAD_STRING rather than accepting the sequence as valid or treating it as a premature string terminator.
Proof embedded in the test comment:
b0 = 0xC0 (192)
ASCII gate: 0xC0 <= 0x7F => 192 <= 127 => FALSE
2-byte gate: 0xC0 >= 0xC2 => 192 >= 194 => FALSE
(0xC0 and 0xC1 are deliberately excluded from [0xC2, 0xDF] per RFC 3629 §3)
All remaining branch predicates also fail for b0 = 0xC0.
Fall-through return 0U -> OKJ_ERROR_BAD_STRING.
https://claude.ai/code/session_01HHohyZBhqxpWqruAGoeDtZ