From: Fabrice Bellard Date: Mon, 22 Dec 2025 14:05:37 +0000 (+0100) Subject: \x{N} is a syntax error X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/NGINX-js-1660x332.png%20%22NGINX%20JavaScript%20Banner%22?a=commitdiff_plain;h=7bd1ae2c76f9053e00e405998a3ea66a995403c4;p=quickjs.git \x{N} is a syntax error --- diff --git a/libregexp.c b/libregexp.c index 42acae8..9d9e361 100644 --- a/libregexp.c +++ b/libregexp.c @@ -757,9 +757,21 @@ int lre_parse_escape(const uint8_t **pp, int allow_utf16) c = '\v'; break; case 'x': + { + int h0, h1; + + h0 = from_hex(*p++); + if (h0 < 0) + return -1; + h1 = from_hex(*p++); + if (h1 < 0) + return -1; + c = (h0 << 4) | h1; + } + break; case 'u': { - int h, n, i; + int h, i; uint32_t c1; if (*p == '{' && allow_utf16) { @@ -777,14 +789,8 @@ int lre_parse_escape(const uint8_t **pp, int allow_utf16) } p++; } else { - if (c == 'x') { - n = 2; - } else { - n = 4; - } - c = 0; - for(i = 0; i < n; i++) { + for(i = 0; i < 4; i++) { h = from_hex(*p++); if (h < 0) { return -1;