https://bugs.exim.org/show_bug.cgi?id=1887
Bug ID: 1887
Summary: Conditional groups fail with definition inside an
assertion inside recursion in non-JIT mode
Product: PCRE
Version: 8.39
Hardware: x86
OS: All
Status: NEW
Severity: bug
Priority: medium
Component: Code
Assignee: ph10@???
Reporter: bobwei9@???
CC: pcre-dev@???
Somehow, when declaring a capturing group inside an assertion, the capturing
group isn't reset when backtracking, if:
- we are recursing into a capturing group via (?&m),
- there has already been another capturing group matched (here: the empty group
"()"),
- and we aren't in JIT mode.
Consider this input:
123
Then following regex fails to match (without JIT):
(?(DEFINE)
(?<m>
1? (?=(?<cond>2)?) 1 2 (?(cond)|3)
)
)
\A
()
(?&m)
\Z
The following regexes work:
\A
(?=())
# inlined version
1? (?=(?<cond>2)?) 1 2 (?(cond)|3)
\Z
and:
(?(DEFINE)
(?<m>
1? (?=(?<cond>2)?) 1 2 (?(cond)|3)
)
)
\A
# no () here
(?&m)
\Z
Similarly, this matches even though it really shouldn't:
(?(DEFINE)
(?<m>
1? (?(cond)12) (?=(?<cond>2)?) 3
)
)
\A
()
(?&m)
\Z
--
You are receiving this mail because:
You are on the CC list for the bug.