mirror of
https://github.com/DoneJS-Runtime/quickjs-done-nextgen.git
synced 2025-01-09 17:43:15 +00:00
regexp: fix non greedy quantizers with zero length matches
Cherry-picked from:
36911f0d3a
This commit is contained in:
parent
763010663b
commit
009a60218f
2 changed files with 10 additions and 4 deletions
10
libregexp.c
10
libregexp.c
|
@ -1633,11 +1633,13 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir)
|
|||
|
||||
if (dbuf_error(&s->byte_code))
|
||||
goto out_of_memory;
|
||||
add_zero_advance_check = (re_check_advance(s->byte_code.buf + last_atom_start,
|
||||
s->byte_code.size - last_atom_start) == 0);
|
||||
} else {
|
||||
add_zero_advance_check = FALSE;
|
||||
}
|
||||
/* the spec tells that if there is no advance when
|
||||
running the atom after the first quant_min times,
|
||||
then there is no match. We remove this test when we
|
||||
are sure the atom always advances the position. */
|
||||
add_zero_advance_check = (re_check_advance(s->byte_code.buf + last_atom_start,
|
||||
s->byte_code.size - last_atom_start) == 0);
|
||||
|
||||
{
|
||||
int len, pos;
|
||||
|
|
|
@ -768,6 +768,10 @@ function test_regexp()
|
|||
|
||||
eval("/[\\-]/");
|
||||
eval("/[\\-]/u");
|
||||
|
||||
/* test zero length matches */
|
||||
a = /()*?a/.exec(",");
|
||||
assert(a, null);
|
||||
}
|
||||
|
||||
function test_symbol()
|
||||
|
|
Loading…
Reference in a new issue