Skip to content

[C++] Escape quote and backslash when writing a single char field as JSON - #1142

Open
slachiewicz wants to merge 1 commit into
aeron-io:masterfrom
slachiewicz:cpp-json-escape-single-char
Open

slachiewicz wants to merge 1 commit into
aeron-io:masterfrom
slachiewicz:cpp-json-escape-single-char

Conversation

@slachiewicz

Copy link
Copy Markdown
Contributor

The generated operator<< writes a single char field between quotes without escaping it, so a field holding " or \ prints "code": """ or "code": "\", which is not valid JSON. Both are now escaped, as get*AsJsonEscapedString() already does for char arrays. The std::isprint argument is also cast to unsigned char, since passing a negative char is undefined behaviour.

Verified: the new JsonCharTest fails on master for " and \, and passes with this change (GCC 12 on arm64 Linux with ASan/UBSan, and AppleClang through CMake).

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.

1 participant