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
15 changes: 9 additions & 6 deletions src/pcre2_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -2707,7 +2707,7 @@ int i;

if (ptr >= ptrend || *ptr != CHAR_LEFT_PARENTHESIS)
{
*errorcodeptr = ERR15;
*errorcodeptr = ERR118;
goto FAILED;
}

Expand All @@ -2716,6 +2716,12 @@ for (;;)
ptr++;
next_offset = (PCRE2_SIZE)(ptr - cb->start_pattern);

if (ptr >= ptrend)
{
*errorcodeptr = ERR117;
goto FAILED;
}

/* Handle [+-]number cases */
if (read_number(&ptr, ptrend, cb->bracount, MAX_GROUP_NUMBER, ERR61,
&i, errorcodeptr))
Expand All @@ -2732,16 +2738,14 @@ for (;;)
else if (*errorcodeptr != 0) goto FAILED; /* Number too big */
else
{
if (ptr >= ptrend) goto UNCLOSED_PARENTHESIS;

/* Handle 'name' or <name> cases. */
if (*ptr == CHAR_LESS_THAN_SIGN)
terminator = CHAR_GREATER_THAN_SIGN;
else if (*ptr == CHAR_APOSTROPHE)
terminator = CHAR_APOSTROPHE;
else
{
*errorcodeptr = ERR15;
*errorcodeptr = ERR117;
goto FAILED;
}

Expand Down Expand Up @@ -4767,8 +4771,7 @@ while (ptr < ptrend)
goto NEGATIVE_LOOK_AHEAD;

case META_SCS:
if (++ptr >= ptrend) goto UNCLOSED_PARENTHESIS;

ptr++;
*parsed_pattern++ = META_SCS;

parsed_pattern = parse_capture_list(&ptr, ptrend, utf, parsed_pattern,
Expand Down
24 changes: 12 additions & 12 deletions src/pcre2_compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ pcre2.h.in must be updated - their values are exactly 100 greater than these
values. */

enum { ERR0 = COMPILE_ERROR_BASE,
ERR1, ERR2, ERR3, ERR4, ERR5, ERR6, ERR7, ERR8, ERR9, ERR10,
ERR11, ERR12, ERR13, ERR14, ERR15, ERR16, ERR17, ERR18, ERR19, ERR20,
ERR21, ERR22, ERR23, ERR24, ERR25, ERR26, ERR27, ERR28, ERR29, ERR30,
ERR31, ERR32, ERR33, ERR34, ERR35, ERR36, ERR37, ERR38, ERR39, ERR40,
ERR41, ERR42, ERR43, ERR44, ERR45, ERR46, ERR47, ERR48, ERR49, ERR50,
ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57, ERR58, ERR59, ERR60,
ERR61, ERR62, ERR63, ERR64, ERR65, ERR66, ERR67, ERR68, ERR69, ERR70,
ERR71, ERR72, ERR73, ERR74, ERR75, ERR76, ERR77, ERR78, ERR79, ERR80,
ERR81, ERR82, ERR83, ERR84, ERR85, ERR86, ERR87, ERR88, ERR89, ERR90,
ERR91, ERR92, ERR93, ERR94, ERR95, ERR96, ERR97, ERR98, ERR99, ERR100,
ERR101,ERR102,ERR103,ERR104,ERR105,ERR106,ERR107,ERR108,ERR109,ERR110,
ERR111,ERR112,ERR113,ERR114,ERR115,ERR116 };
ERR1, ERR2, ERR3, ERR4, ERR5, ERR6, ERR7, ERR8, ERR9, ERR10,
ERR11, ERR12, ERR13, ERR14, ERR15, ERR16, ERR17, ERR18, ERR19, ERR20,
ERR21, ERR22, ERR23, ERR24, ERR25, ERR26, ERR27, ERR28, ERR29, ERR30,
ERR31, ERR32, ERR33, ERR34, ERR35, ERR36, ERR37, ERR38, ERR39, ERR40,
ERR41, ERR42, ERR43, ERR44, ERR45, ERR46, ERR47, ERR48, ERR49, ERR50,
ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57, ERR58, ERR59, ERR60,
ERR61, ERR62, ERR63, ERR64, ERR65, ERR66, ERR67, ERR68, ERR69, ERR70,
ERR71, ERR72, ERR73, ERR74, ERR75, ERR76, ERR77, ERR78, ERR79, ERR80,
ERR81, ERR82, ERR83, ERR84, ERR85, ERR86, ERR87, ERR88, ERR89, ERR90,
ERR91, ERR92, ERR93, ERR94, ERR95, ERR96, ERR97, ERR98, ERR99, ERR100,
ERR101, ERR102, ERR103, ERR104, ERR105, ERR106, ERR107, ERR108, ERR109, ERR110,
ERR111, ERR112, ERR113, ERR114, ERR115, ERR116, ERR117, ERR118 };

/* Code values for parsed patterns, which are stored in a vector of 32-bit
unsigned ints. Values less than META_END are literal data values. The coding
Expand Down
2 changes: 2 additions & 0 deletions src/pcre2_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ static const unsigned char compile_error_texts[] =
/* 115 */
"terminating ] with no following closing parenthesis in (?[...]\0"
"unexpected character in (?[...]) extended character class\0"
"expected capture group number or name\0"
"missing opening parenthesis\0"
;

/* Match-time and UTF error texts are in the same format. */
Expand Down
2 changes: 2 additions & 0 deletions testdata/testinput2
Original file line number Diff line number Diff line change
Expand Up @@ -7838,6 +7838,8 @@ a)"xI

/(?1:1/

/(?R:(1/

/(?R:(1,/

/(?R0:(1,2!/
Expand Down
13 changes: 8 additions & 5 deletions testdata/testoutput2
Original file line number Diff line number Diff line change
Expand Up @@ -18812,10 +18812,10 @@ No match
# Parse errors first

/(*scs:/
Failed: error 114 at offset 6: missing closing parenthesis
Failed: error 218 at offset 6: missing opening parenthesis

/(*scan_substring:(/
Failed: error 114 at offset 18: missing closing parenthesis
Failed: error 217 at offset 18: expected capture group number or name

/(*scs:('name'/
Failed: error 114 at offset 13: missing closing parenthesis
Expand Down Expand Up @@ -21885,13 +21885,16 @@ Failed: error -69: error performing replacement case transformation
# Parse error tests

/(?1:/
Failed: error 115 at offset 4: reference to non-existent subpattern
Failed: error 218 at offset 4: missing opening parenthesis

/(?1:1/
Failed: error 115 at offset 4: reference to non-existent subpattern
Failed: error 218 at offset 4: missing opening parenthesis

/(?R:(1/
Failed: error 114 at offset 6: missing closing parenthesis

/(?R:(1,/
Failed: error 114 at offset 7: missing closing parenthesis
Failed: error 217 at offset 7: expected capture group number or name

/(?R0:(1,2!/
Failed: error 158 at offset 3: (?R (recursive pattern call) must be followed by a closing parenthesis
Expand Down
Loading