Skip to content

parser: accept only RFC 8259 whitespace between tokens - #1076

Open
AetherAI3 wants to merge 1 commit into
DaveGamble:masterfrom
AetherAI3:fix/1074-rfc8259-whitespace
Open

parser: accept only RFC 8259 whitespace between tokens#1076
AetherAI3 wants to merge 1 commit into
DaveGamble:masterfrom
AetherAI3:fix/1074-rfc8259-whitespace

Conversation

@AetherAI3

Copy link
Copy Markdown

Closes #1074.

buffer_skip_whitespace treated every byte <= 32 as whitespace, so NUL (0x00), 0x01, 0x0b, 0x0c, 0x1f, and every other C0 control byte were silently skipped between tokens. RFC 8259 whitespace is only 0x20, 0x09, 0x0a, 0x0d.

Before:
cJSON_ParseWithLengthOpts("[\x0b1]", 5, NULL, 1) -> [1]
cJSON_ParseWithLengthOpts("[\x011]", 5, NULL, 1) -> [1]
cJSON_ParseWithLengthOpts("\x00null", 6, NULL, 1) -> null

After: all three return NULL. Existing whitespace inputs (space, tab, newline, CR, mixed) still parse identically.

Reported by @nassersala. In-tree ctest -j4 -> 19/19 pass on the patched build.

Closes DaveGamble#1074.

buffer_skip_whitespace treated every byte <= 32 as whitespace, so
NUL (0x00), 0x01, 0x0b, 0x0c, 0x1f, and every other C0 control
byte were silently skipped between tokens. RFC 8259 whitespace is
only 0x20, 0x09, 0x0a, 0x0d.

Before:
  cJSON_ParseWithLengthOpts("[\\x0b1]", 5, NULL, 1)  -> [1]
  cJSON_ParseWithLengthOpts("[\\x011]", 5, NULL, 1)  -> [1]
  cJSON_ParseWithLengthOpts("\\x00null", 6, NULL, 1) -> null

After: all three return NULL. Existing whitespace inputs (space,
tab, newline, CR, mixed) still parse identically.

Reported by @nassersala. In-tree ctest -j4 -> 19/19 pass on the
patched build.

Signed-off-by: Brandon Barrante <aetherai@aethersystems.net>
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.

buffer_skip_whitespace accepts every byte below 0x21 as whitespace

1 participant