summaryrefslogtreecommitdiff
path: root/lib/jsonParse.impl.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-05-01 20:23:19 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2021-11-07 16:41:37 +0000
commitfd8363a62cc2c1318a0b58b442c3fbc451554fa2 (patch)
treedf7f2a5700d3a0ed7c35ff3609cd0453386ec4c5 /lib/jsonParse.impl.cpp
parentPass new values more efficiently (diff)
downloadilt-fd8363a62cc2c1318a0b58b442c3fbc451554fa2.tar.bz2
ilt-fd8363a62cc2c1318a0b58b442c3fbc451554fa2.tar.xz
ilt-fd8363a62cc2c1318a0b58b442c3fbc451554fa2.zip
Fixup clang, cppcheck and iwyu warnings
Diffstat (limited to 'lib/jsonParse.impl.cpp')
-rw-r--r--lib/jsonParse.impl.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/jsonParse.impl.cpp b/lib/jsonParse.impl.cpp
index 4d13eae..0913847 100644
--- a/lib/jsonParse.impl.cpp
+++ b/lib/jsonParse.impl.cpp
@@ -25,7 +25,7 @@ json::jsonParser::appendEscape(unsigned long cp, std::string & str)
str += char((cp >> 6) + 192);
str += char((cp & 63) + 128);
}
- else if (0xd800 <= cp && cp <= 0xdfff) {
+ else if ((0xd800 <= cp && cp <= 0xdfff) || cp > 0x10FFFF) {
throw std::range_error("Invalid UTF-8 sequence");
}
else if (cp <= 0xFFFF) {
@@ -33,13 +33,10 @@ json::jsonParser::appendEscape(unsigned long cp, std::string & str)
str += char(((cp >> 6) & 63) + 128);
str += char((cp & 63) + 128);
}
- else if (cp <= 0x10FFFF) {
+ else {
str += char((cp >> 18) + 240);
str += char(((cp >> 12) & 63) + 128);
str += char(((cp >> 6) & 63) + 128);
str += char((cp & 63) + 128);
}
- else {
- throw std::range_error("Invalid UTF-8 sequence");
- }
}