Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/pcre2_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -9370,10 +9370,10 @@ return c;

/* This function is called to skip parts of the parsed pattern when finding the
length of a lookbehind branch. It is called after (*ACCEPT) and (*FAIL) to find
the end of the branch, it is called to skip over an internal lookaround or
(DEFINE) group, and it is also called to skip to the end of a class, during
which it will never encounter nested groups (but there's no need to have
special code for that).
the end of the branch; it is called to skip over an internal lookaround or
(DEFINE) group; and it is also called to skip to the end of a class, during
which it will never encounter nested groups (however extended classes can
themselves be nested, with their own class-nesting level).

When called to find the end of a branch or group, pptr must point to the first
meta code inside the branch, not the branch-starting code. In other cases it
Expand All @@ -9394,6 +9394,7 @@ static uint32_t *
parsed_skip(uint32_t *pptr, uint32_t skiptype)
{
uint32_t nestlevel = 0;
uint32_t class_nestlevel = 0;

for (;; pptr++)
{
Expand Down Expand Up @@ -9433,12 +9434,19 @@ for (;; pptr++)
pptr += pptr[1];
break;

/* These are the "active" items in this loop. */
/* These are the active items for tracking class nesting. */

case META_CLASS:
case META_CLASS_NOT:
if (skiptype == PSKIP_CLASS) class_nestlevel++;
break;

case META_CLASS_END:
if (skiptype == PSKIP_CLASS) return pptr;
if (skiptype == PSKIP_CLASS && --class_nestlevel == 0) return pptr;
break;

/* These are the "active" items for tracking ALT/KET nesting. */

case META_ATOMIC:
case META_CAPTURE:
case META_COND_ASSERT:
Expand Down
10 changes: 10 additions & 0 deletions testdata/testinput2
Original file line number Diff line number Diff line change
Expand Up @@ -7400,6 +7400,16 @@ a)"xI

/[z&/alt_extended_class

/(?<=[12[34]])/alt_extended_class
1
2
3
4
1]
\= Expect no match
5
[]

/[[^]~~[^]]/B,alt_extended_class,allow_empty_class
\= Expect no match
a
Expand Down
17 changes: 17 additions & 0 deletions testdata/testoutput2
Original file line number Diff line number Diff line change
Expand Up @@ -21773,6 +21773,23 @@ Failed: error 207 at offset 117: extended character class nesting is too deep
Failed: error 106 at offset 3: missing terminating ] for character class
here: [z& |<--|

/(?<=[12[34]])/alt_extended_class
1
0:
2
0:
3
0:
4
0:
1]
0:
\= Expect no match
5
No match
[]
No match

/[[^]~~[^]]/B,alt_extended_class,allow_empty_class
------------------------------------------------------------------
Bra
Expand Down
Loading