From: Fabrice Bellard Date: Sat, 26 Sep 2026 11:01:30 +0000 (+0200) Subject: fixed regexp unicode set parsing (#520) X-Git-Url: https://git.kaiwu.me/%7B@url%7D?a=commitdiff_plain;h=a479eff9e24a6608a7c587c6b3a5a3ac690b26f1;p=quickjs.git fixed regexp unicode set parsing (#520) --- diff --git a/libregexp.c b/libregexp.c index c387f00..b231e95 100644 --- a/libregexp.c +++ b/libregexp.c @@ -1183,7 +1183,7 @@ static int get_class_atom(REParseState *s, REStringList *cr, case '^': case '`': case '~': - if (s->unicode_sets && p[1] == c) { + if (inclass && s->unicode_sets && p[1] == c) { /* forbidden double characters */ return re_parse_error(s, "invalid class set operation in regular expression"); } @@ -1198,7 +1198,7 @@ static int get_class_atom(REParseState *s, REStringList *cr, case '/': case '-': case '|': - if (s->unicode_sets) { + if (inclass && s->unicode_sets) { /* invalid characters in unicode sets */ return re_parse_error(s, "invalid character in class in regular expression"); } diff --git a/tests/test_builtin.js b/tests/test_builtin.js index 14bcc06..c20d740 100644 --- a/tests/test_builtin.js +++ b/tests/test_builtin.js @@ -805,6 +805,9 @@ function test_regexp() a = a.exec("\u{10000}_\u{10000}"); assert(a.indices[0][0], 0); assert(a.indices[0][1], 2); + + /* syntax check */ + assert(/-&&/v.test("-&&"), true); } function test_symbol()