File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -255,22 +255,22 @@ static const char *echttp_json_string (JsonContext context) {
255255 l = hex2bin (from [4 ]);
256256 if (h < 0 || l < 0 ) return "invalid unicode" ;
257257 ucode += 16 * h + l ;
258- if (from [ 5 ] != '\\' || from [ 6 ] != 'u' ) {
258+ if (ucode < 0xd800 || ucode >= 0xe000 ) {
259259 // Convert UTF-16 to UTF-8:
260260 if (ucode < 0x80 ) {
261261 * to ++ = (char ) (ucode & 0x7f );
262262 } else if (ucode < 0x800 ) {
263263 * to ++ = 0xc0 + ((ucode >> 6 ) & 0x1f );
264264 * to ++ = 0x80 + (ucode & 0x3f );
265- } else if (ucode >= 0xD800 ) {
266- return "reserved UTF-16 character" ;
267265 } else {
268266 * to ++ = 0xc0 + ((ucode >> 12 ) & 0x1f );
269267 * to ++ = 0x80 + ((ucode > 6 ) & 0x3f );
270268 * to ++ = 0x80 + (ucode & 0x3f );
271269 }
272270 from += 4 ;
273271 } else {
272+ if (from [5 ] != '\\' || from [6 ] != 'u' )
273+ return "missing 2nd half of surrogate pair" ;
274274 // UTF-32 coded as a surrogate pair.
275275 ucode -= 0xd800 ;
276276 if (ucode < 0 || ucode > 0x3ff )
You can’t perform that action at this time.
0 commit comments