Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libregexp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions tests/test_builtin.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,9 @@ function test_regexp()
ex = _ex;
}
assert(ex?.message, "invalid class range");

eval("/[\\-]/");
eval("/[\\-]/u");
}

function test_symbol()
Expand Down