[pcre-dev] [Bug 1887] Conditional groups fail with definitio…

Góra strony
Delete this message
Autor: admin
Data:  
Dla: pcre-dev
Temat: [pcre-dev] [Bug 1887] Conditional groups fail with definition inside an assertion inside recursion in non-JIT mode
https://bugs.exim.org/show_bug.cgi?id=1887

--- Comment #1 from Philip Hazel <ph10@???> ---
Congratulations! You have discovered a very subtle bug that has probably been
in PCRE since assertions and conditional groups were added to the very basic
original library, back in the late 1990s. I am a bit surprised nobody has
noticed before. In fact, it doesn't need recursion in order to provoke it. This
pattern:

^(?:
(?: A| (1? (?=(?<cond>2)?) (1) 2 (?('cond')|3)) )
(Z)
)+$

(ignoring white space) matches "AZ12Z" when it shouldn't, and doesn't match
"AZ123Z" when it should. The bug is that it does not reset groups that are
captured in an assertion when the assertion is backtracked over - but this is
masked when the groups in question have higher numbers that the last group
otherwise set, because that value *does* get reset. That is why you need the ()
in your example, and mine needs (Z).

The bad news is that I do not at present know how to fix this without using up
a lot more stack in all cases. I am, however, actively working on it, and hope
to find a solution shortly that only uses more stack when an assertion contains
capturing groups.

--
You are receiving this mail because:
You are on the CC list for the bug.