mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
fix(regular_expression): Handle unterminated character class (#5523)
`/[/` is reported by `debug_assert!`, but should not.
This commit is contained in:
parent
10e8984d93
commit
88b7ddb7e0
2 changed files with 8 additions and 1 deletions
|
|
@ -171,6 +171,10 @@ mod test {
|
|||
("(?=a){1}", ParserOptions::default().with_unicode_mode()),
|
||||
("(?!a){1}", ParserOptions::default().with_unicode_mode()),
|
||||
(r"[\d-\D]", ParserOptions::default().with_unicode_mode()),
|
||||
("[", ParserOptions::default()),
|
||||
("[", ParserOptions::default().with_unicode_sets_mode()),
|
||||
("[[", ParserOptions::default().with_unicode_sets_mode()),
|
||||
("[[]", ParserOptions::default().with_unicode_sets_mode()),
|
||||
("[z-a]", ParserOptions::default()),
|
||||
(r"[a-c]]", ParserOptions::default().with_unicode_mode()),
|
||||
(
|
||||
|
|
|
|||
|
|
@ -771,7 +771,10 @@ impl<'a> PatternParser<'a> {
|
|||
&mut self,
|
||||
) -> Result<(ast::CharacterClassContentsKind, Vec<'a, ast::CharacterClassContents<'a>>)> {
|
||||
// [empty]
|
||||
if self.reader.peek().filter(|&cp| cp == ']' as u32).is_some() {
|
||||
if self.reader.peek().filter(|&cp| cp == ']' as u32).is_some()
|
||||
// Unterminated
|
||||
|| self.reader.peek().is_none()
|
||||
{
|
||||
return Ok((ast::CharacterClassContentsKind::Union, Vec::new_in(self.allocator)));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue