schemagen: escape control characters in generated C++ string literals #48

Merged
andrew merged 1 commits from weaselbot/weaseljson:weaselbot/issue-35 into main 2026-06-30 16:30:23 +00:00
Member

Closes #35

Closes #35
weaselbot added 1 commit 2026-06-30 16:26:18 +00:00
schemagen: escape control characters in generated C++ string literals
CI / pre-commit (pull_request) Successful in 53s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 53s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m32s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 52s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m28s
681892107f
Fixes #35.

Add a helper to escape C++ string literals so that JSON control characters
(\n, \r, \t, and other bytes below 0x20) are emitted as escape sequences
instead of raw bytes. Use it for:

- field comments that include the JSON property key
- object key comparison literals in matchKey()
- enum name arrays

Also add regression tests that generate and syntax-check headers for
schemas containing newlines and other control characters in property keys
and enum values.
andrew scheduled this pull request to auto merge when all checks succeed 2026-06-30 16:27:51 +00:00
andrew merged commit f6617a1558 into main 2026-06-30 16:30:23 +00:00
andrew deleted branch weaselbot/issue-35 2026-06-30 16:30:24 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: weaselab/weaseljson#48