From 8049b358ee9624988bcf87c768ede10fed324db5 Mon Sep 17 00:00:00 2001 From: Vladimir Shabanov Date: Fri, 21 Oct 2016 01:54:55 +0300 Subject: [PATCH] Fixed "Invalid UTF-8 stream" error on valid characters (#476). --- cbits/unescape_string.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cbits/unescape_string.c b/cbits/unescape_string.c index 2d31209..d62499c 100644 --- a/cbits/unescape_string.c +++ b/cbits/unescape_string.c @@ -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 @@ -147,4 +147,3 @@ int _js_decode_string(uint16_t *const dest, size_t *destoff, if (codepoint != 'u') { return -1; } DISPATCH_ASCII(unicode1) } -