[Pcre-svn] [1582] code/trunk: Fix (?R- not being diagnosed c…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [1582] code/trunk: Fix (?R- not being diagnosed correctly.
Revision: 1582
          http://vcs.pcre.org/viewvc?view=rev&revision=1582
Author:   ph10
Date:     2015-07-22 10:33:04 +0100 (Wed, 22 Jul 2015)
Log Message:
-----------
Fix (?R- not being diagnosed correctly.


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/pcre_compile.c
    code/trunk/testdata/testinput2
    code/trunk/testdata/testoutput2


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2015-07-22 09:06:15 UTC (rev 1581)
+++ code/trunk/ChangeLog    2015-07-22 09:33:04 UTC (rev 1582)
@@ -88,13 +88,16 @@
     compiled and could cause reading from uninitialized memory or an incorrect
     error diagnosis.


-16. Pathological patterns containing many nested occurrences of [: caused 
+23. Pathological patterns containing many nested occurrences of [: caused 
     pcre_compile() to run for a very long time.


-17. A conditional group with only one branch has an implicit empty alternative
+24. A conditional group with only one branch has an implicit empty alternative
     branch and must therefore be treated as potentially matching an empty
     string.


+25. If (?R was followed by - or + incorrect behaviour happened instead of a
+    diagnostic. 
+     


Version 8.37 28-April-2015
--------------------------

Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c    2015-07-22 09:06:15 UTC (rev 1581)
+++ code/trunk/pcre_compile.c    2015-07-22 09:33:04 UTC (rev 1582)
@@ -3936,7 +3936,7 @@
 terminator = *(++ptr);   /* compiler warns about "non-constant" initializer. */
 for (++ptr; *ptr != CHAR_NULL; ptr++)
   {
-  if (*ptr == CHAR_BACKSLASH && 
+  if (*ptr == CHAR_BACKSLASH &&
       (ptr[1] == CHAR_RIGHT_SQUARE_BRACKET ||
        ptr[1] == CHAR_BACKSLASH))
     ptr++;
@@ -6274,13 +6274,13 @@
               }
             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. */


           if (*bracode == OP_COND && bracode[GET(bracode,1)] != OP_ALT)
-            *bracode = OP_SCOND; 
- 
+            *bracode = OP_SCOND;
+
           /* Handle possessive quantifiers. */


           if (possessive_quantifier)
@@ -7337,9 +7337,14 @@



         /* ------------------------------------------------------------ */
-        case CHAR_R:              /* Recursion */
-        ptr++;                    /* Same as (?0)      */
-        /* Fall through */
+        case CHAR_R:              /* Recursion, same as (?0) */
+        recno = 0;
+        if (*(++ptr) != CHAR_RIGHT_PARENTHESIS)
+          {
+          *errorcodeptr = ERR29;
+          goto FAILED;
+          }
+        goto HANDLE_RECURSION;



         /* ------------------------------------------------------------ */


Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2015-07-22 09:06:15 UTC (rev 1581)
+++ code/trunk/testdata/testinput2    2015-07-22 09:33:04 UTC (rev 1582)
@@ -4190,4 +4190,6 @@


/()(?(R)0)*+/BZ

+/(?R-:(?</
+
/-- End of testinput2 --/

Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2015-07-22 09:06:15 UTC (rev 1581)
+++ code/trunk/testdata/testoutput2    2015-07-22 09:33:04 UTC (rev 1582)
@@ -14523,4 +14523,7 @@
         End
 ------------------------------------------------------------------


+/(?R-:(?</
+Failed: (?R or (?[+-]digits must be followed by ) at offset 3
+
/-- End of testinput2 --/