Skip to content

Commit

Permalink
Fixed "Invalid UTF-8 stream" error on valid characters (#476).
Browse files Browse the repository at this point in the history
  • Loading branch information
vshabanov committed Oct 20, 2016
1 parent d9f0374 commit 8049b35
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions cbits/unescape_string.c
Expand Up @@ -130,7 +130,7 @@ int _js_decode_string(uint16_t *const dest, size_t *destoff,
*d++ = (uint16_t) unidata;

if (surrogate) {
if (unidata <= 0xDC00 || unidata >= 0xDFFF) // is not low surrogate
if (unidata < 0xDC00 || unidata > 0xDFFF) // is not low surrogate
return -1;
surrogate = 0;
} else if (unidata >= 0xD800 && unidata <= 0xDBFF ) { // is high surrogate
Expand All @@ -147,4 +147,3 @@ int _js_decode_string(uint16_t *const dest, size_t *destoff,
if (codepoint != 'u') { return -1; }
DISPATCH_ASCII(unicode1)
}

0 comments on commit 8049b35

Please sign in to comment.