Skip to content

test: add RFC 8259 bare control character rejection tests#40

Merged
ionux merged 1 commit intomainfrom
claude/test-control-characters-EkuSo
Mar 12, 2026
Merged

test: add RFC 8259 bare control character rejection tests#40
ionux merged 1 commit intomainfrom
claude/test-control-characters-EkuSo

Conversation

@ionux
Copy link
Copy Markdown
Owner

@ionux ionux commented Mar 12, 2026

Add two tests that prove the < 0x20U boundary check in the string-scan loop correctly returns OKJ_ERROR_BAD_STRING without crashing:

  • test_control_char_tab_in_string_value: injects a literal horizontal-tab byte (0x09) inside a JSON string value via a hex escape in a string literal.

  • test_control_char_lf_in_string_value: injects a literal line-feed byte (0x0A, i.e. the raw byte — not the \n escape sequence) inside a JSON string value, built as an explicit char array to make the injection unambiguous.

Both bytes satisfy 0xXX < 0x20U, so the parser must reject them per RFC 8259 §7 which forbids unescaped control characters U+0000–U+001F.

https://claude.ai/code/session_01Vr1Jm2ua9DbFizRM936Gdf

Add two tests that prove the < 0x20U boundary check in the string-scan
loop correctly returns OKJ_ERROR_BAD_STRING without crashing:

- test_control_char_tab_in_string_value: injects a literal horizontal-tab
  byte (0x09) inside a JSON string value via a hex escape in a string
  literal.

- test_control_char_lf_in_string_value: injects a literal line-feed byte
  (0x0A, i.e. the raw byte — not the \n escape sequence) inside a JSON
  string value, built as an explicit char array to make the injection
  unambiguous.

Both bytes satisfy 0xXX < 0x20U, so the parser must reject them per
RFC 8259 §7 which forbids unescaped control characters U+0000–U+001F.

https://claude.ai/code/session_01Vr1Jm2ua9DbFizRM936Gdf
@ionux ionux merged commit 3ad3f47 into main Mar 12, 2026
2 checks passed
@ionux ionux deleted the claude/test-control-characters-EkuSo branch March 12, 2026 03:04
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.

2 participants