]> git.kaiwu.me - quickjs.git/commitdiff
Fix rejection of escaped reserved punctuators in v-flag \q (Samir)
authorFabrice Bellard <fabrice@bellard.org>
Tue, 24 Nov 2026 17:06:22 +0000 (18:06 +0100)
committerFabrice Bellard <fabrice@bellard.org>
Tue, 24 Nov 2026 17:06:22 +0000 (18:06 +0100)
libregexp.c

index b231e95343ed2fde6062297420cc2cae0f4f5dd7..a66c62235c34989647f27139d4dab8934193ab55 100644 (file)
@@ -1008,7 +1008,7 @@ static int parse_class_string_disjunction(REParseState *s, REStringList *cr,
     for(;;) {
         str.size = 0;
         while (*p != '}' && *p != '|') {
-            c = get_class_atom(s, NULL, &p, FALSE);
+            c = get_class_atom(s, NULL, &p, TRUE);
             if (c < 0)
                 goto fail;
             if (dbuf_put_u32(&str, c)) {
@@ -1102,6 +1102,23 @@ static int get_class_atom(REParseState *s, REStringList *cr,
             if (!inclass && s->is_unicode)
                 goto invalid_escape;
             break;
+        case '&':
+        case '!':
+        case '#':
+        case '%':
+        case ',':
+        case ':':
+        case ';':
+        case '<':
+        case '=':
+        case '>':
+        case '@':
+        case '`':
+        case '~':
+            if (s->is_unicode && (!inclass || !s->unicode_sets))
+                /* Only illegal if in unicode mode and not in a class */
+                goto invalid_escape;
+            break;
         case '^':
         case '$':
         case '\\':