mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-26 10:41:03 +08:00
json_writer: fix inverted sense in isAnyCharRequiredQuoting (#1120)
This bug is only affects platforms where `char` is unsigned. When char is a signed type, values >= 0x80 are also considered < 0, and hence require escaping due to the < ' ' condition. When char is an unsigned type, values >= 0x80 match none of the conditions and are considered safe to emit without escaping. This shows up as a test failure: * Detail of EscapeSequenceTest/writeEscapeSequence test failure: /build/source/src/test_lib_json/main.cpp(3370): expected == result Expected: '["\"","\\","\b","\f","\n","\r","\t","\u0278","\ud852\udf62"] ' Actual : '["\"","\\","\b","\f","\n","\r","\t","ɸ","𤭢"] '
This commit is contained in:
parent
8f7f35c5cd
commit
f11611c878
@ -178,8 +178,9 @@ static bool isAnyCharRequiredQuoting(char const* s, size_t n) {
|
|||||||
|
|
||||||
char const* const end = s + n;
|
char const* const end = s + n;
|
||||||
for (char const* cur = s; cur < end; ++cur) {
|
for (char const* cur = s; cur < end; ++cur) {
|
||||||
if (*cur == '\\' || *cur == '\"' || *cur < ' ' ||
|
if (*cur == '\\' || *cur == '\"' ||
|
||||||
static_cast<unsigned char>(*cur) < 0x80)
|
static_cast<unsigned char>(*cur) < ' ' ||
|
||||||
|
static_cast<unsigned char>(*cur) >= 0x80)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user