Fix (?R- not being correctly diagnosed.

This commit is contained in:
Philip.Hazel 2015-07-22 09:29:09 +00:00
parent 0046526d0e
commit e4d630c4af
4 changed files with 26 additions and 13 deletions

View File

@ -69,6 +69,9 @@ the LLVM fuzzer.
18. A conditional group with only one branch has an implicit empty alternative 18. A conditional group with only one branch has an implicit empty alternative
branch and must therefore be treated as potentially matching an empty string. branch and must therefore be treated as potentially matching an empty string.
19. If (?R was followed by - or + incorrect behaviour happened instead of a
diagnostic. This bug was discovered by Karl Skomski with the LLVM fuzzer.
Version 10.20 30-June-2015 Version 10.20 30-June-2015
-------------------------- --------------------------

View File

@ -2583,8 +2583,8 @@ when Perl does, I think.
A user pointed out that PCRE was rejecting [:a[:digit:]] whereas Perl was not. A user pointed out that PCRE was rejecting [:a[:digit:]] whereas Perl was not.
It seems that the appearance of a nested POSIX class supersedes an apparent It seems that the appearance of a nested POSIX class supersedes an apparent
external class. For example, [:a[:digit:]b:] matches "a", "b", ":", or external class. For example, [:a[:digit:]b:] matches "a", "b", ":", or
a digit. This is handled by returning FALSE if the start of a new group with a digit. This is handled by returning FALSE if the start of a new group with
the same terminator is encountered, since the next closing sequence must close the same terminator is encountered, since the next closing sequence must close
the nested group, not the outer one. the nested group, not the outer one.
In Perl, unescaped square brackets may also appear as part of class names. For In Perl, unescaped square brackets may also appear as part of class names. For
@ -3282,7 +3282,7 @@ for (; ptr < cb->end_pattern; ptr++)
/* Handle a string argument */ /* Handle a string argument */
else else
{ {
ptr++; ptr++;
delimiter = 0; delimiter = 0;
for (i = 0; PRIV(callout_start_delims)[i] != 0; i++) for (i = 0; PRIV(callout_start_delims)[i] != 0; i++)
@ -3293,13 +3293,13 @@ for (; ptr < cb->end_pattern; ptr++)
break; break;
} }
} }
if (delimiter == 0) if (delimiter == 0)
{ {
errorcode = ERR82; errorcode = ERR82;
goto FAILED; goto FAILED;
} }
start = ptr; start = ptr;
do do
{ {
@ -3312,8 +3312,8 @@ for (; ptr < cb->end_pattern; ptr++)
if (ptr[0] == delimiter && ptr[1] == delimiter) ptr += 2; if (ptr[0] == delimiter && ptr[1] == delimiter) ptr += 2;
} }
while (ptr[0] != delimiter); while (ptr[0] != delimiter);
} }
/* Check terminating ) */ /* Check terminating ) */
if (ptr[1] != CHAR_RIGHT_PARENTHESIS) if (ptr[1] != CHAR_RIGHT_PARENTHESIS)
@ -5324,12 +5324,12 @@ for (;; ptr++)
scode += GET(scode, 1); scode += GET(scode, 1);
} }
while (*scode == OP_ALT); while (*scode == OP_ALT);
/* A conditional group with only one branch has an implicit empty /* A conditional group with only one branch has an implicit empty
alternative branch. */ alternative branch. */
if (*bracode == OP_COND && bracode[GET(bracode,1)] != OP_ALT) if (*bracode == OP_COND && bracode[GET(bracode,1)] != OP_ALT)
*bracode = OP_SCOND; *bracode = OP_SCOND;
} }
/* Handle possessive quantifiers. */ /* Handle possessive quantifiers. */
@ -6394,9 +6394,14 @@ for (;; ptr++)
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
case CHAR_R: /* Recursion */ case CHAR_R: /* Recursion, same as (?0) */
ptr++; /* Same as (?0) */ recno = 0;
/* Fall through */ if (*(++ptr) != CHAR_RIGHT_PARENTHESIS)
{
*errorcodeptr = ERR29;
goto FAILED;
}
goto HANDLE_RECURSION;
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */

2
testdata/testinput2 vendored
View File

@ -4354,4 +4354,6 @@ a random value. /Ix
/()(?(R)0)*+/B /()(?(R)0)*+/B
/(?R-:(?</
# End of testinput2 # End of testinput2

View File

@ -14553,4 +14553,7 @@ Failed: error 106 at offset 353: missing terminating ] for character class
End End
------------------------------------------------------------------ ------------------------------------------------------------------
/(?R-:(?</
Failed: error 129 at offset 3: (?R or (?[+-]digits must be followed by )
# End of testinput2 # End of testinput2