Accept /[\-]/u as a valid regular expression (#288)
The non-Unicode version of the pattern was already accepted. test262 tests it in an inverted sense in test/built-ins/RegExp/unicode_restricted_identity_escape.js but it appears to be per spec and both V8 and Spidermonkey accept it. Fixes: https://github.com/quickjs-ng/quickjs/issues/286
This commit is contained in:
parent
7dd2868856
commit
f406d6f78c
2 changed files with 6 additions and 0 deletions
|
@ -783,6 +783,9 @@ static int get_class_atom(REParseState *s, CharRange *cr,
|
|||
/* always valid to escape these characters */
|
||||
goto normal_char;
|
||||
} else if (s->is_unicode) {
|
||||
// special case: allowed inside [] but not outside
|
||||
if (ret == -2 && *p == '-' && inclass)
|
||||
goto normal_char;
|
||||
invalid_escape:
|
||||
return re_parse_error(s, "invalid escape sequence in regular expression");
|
||||
} else {
|
||||
|
|
|
@ -699,6 +699,9 @@ function test_regexp()
|
|||
ex = _ex;
|
||||
}
|
||||
assert(ex?.message, "invalid class range");
|
||||
|
||||
eval("/[\\-]/");
|
||||
eval("/[\\-]/u");
|
||||
}
|
||||
|
||||
function test_symbol()
|
||||
|
|
Loading…
Reference in a new issue