[pcre-dev] [Bug 2792] \K should not be allowed in lookaround…

Pàgina inicial
Delete this message
Autor: admin
Data:  
A: pcre-dev
Assumpte: [pcre-dev] [Bug 2792] \K should not be allowed in lookarounds
https://bugs.exim.org/show_bug.cgi?id=2792

--- Comment #10 from Philip Hazel <Philip.Hazel@???> ---
OH SILLY ME. I should have looked more closely at the code in pcre2demo. It has
special code to deal with this case. Here is the comment:

/* If the previous match was not an empty string, there is one tricky case to
consider. If a pattern contains \K within a lookbehind assertion at the
start, the end of the matched string can be at the offset where the match
started. Without special action, this leads to a loop that keeps on matching
the same substring. We must detect this case and arrange to move the start on
by one character. The pcre2_get_startchar() function returns the starting
offset that was passed to pcre2_match(). */

OK, so now all is understood (pcre2test no doubt does the same). Perhaps the
best thing to do here is to forbid \K in assertions, but to implement a new
option in the PCRE2_EXTRA series to allow the current implementation. Then
anyone who really needs the current behaviour can get it. We can put lots of
warnings in the docs.

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