[Pcre-svn] [1667] code/trunk: Fix bad conditional recursion …

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [1667] code/trunk: Fix bad conditional recursion test bug when a group with name starting "R "
Revision: 1667
          http://vcs.pcre.org/viewvc?view=rev&revision=1667
Author:   ph10
Date:     2016-10-13 17:00:48 +0100 (Thu, 13 Oct 2016)
Log Message:
-----------
Fix bad conditional recursion test bug when a group with name starting "R" 
exists.


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    2016-10-06 17:49:48 UTC (rev 1666)
+++ code/trunk/ChangeLog    2016-10-13 16:00:48 UTC (rev 1667)
@@ -19,15 +19,23 @@


5. Fix JIT unaligned accesses on x86. Patch by Marc Mutz.

-6. In any wide-character mode (8-bit UTF or any 16-bit or 32-bit mode), without
-   PCRE_UCP set, a negative character type such as \D in a positive class
-   should cause all characters greater than 255 to match, whatever else is in
-   the class. There was a bug that caused this not to happen if a Unicode
-   property item was added to such a class, for example [\D\P{Nd}] or [\W\pL].
-   
-7. When pcretest was outputing information from a callout, the caret indicator
-   for the current position in the subject line was incorrect if it was after
-   an escape sequence for a character whose code point was greater than \x{ff}.
+6.  In any wide-character mode (8-bit UTF or any 16-bit or 32-bit mode),
+    without PCRE_UCP set, a negative character type such as \D in a positive
+    class should cause all characters greater than 255 to match, whatever else
+    is in the class. There was a bug that caused this not to happen if a
+    Unicode property item was added to such a class, for example [\D\P{Nd}] or
+    [\W\pL].
+    
+7.  When pcretest was outputing information from a callout, the caret indicator
+    for the current position in the subject line was incorrect if it was after
+    an escape sequence for a character whose code point was greater than
+    \x{ff}.
+    
+8.  A pattern such as (?<RA>abc)(?(R)xyz) was incorrectly compiled such that
+    the conditional was interpreted as a reference to capturing group 1 instead
+    of a test for recursion. Any group whose name began with R was
+    misinterpreted in this way. (The reference interpretation should only 
+    happen if the group's name is precisely "R".)



Version 8.39 14-June-2016

Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c    2016-10-06 17:49:48 UTC (rev 1666)
+++ code/trunk/pcre_compile.c    2016-10-13 16:00:48 UTC (rev 1667)
@@ -6951,7 +6951,8 @@
         slot = cd->name_table;
         for (i = 0; i < cd->names_found; i++)
           {
-          if (STRNCMP_UC_UC(name, slot+IMM2_SIZE, namelen) == 0) break;
+          if (STRNCMP_UC_UC(name, slot+IMM2_SIZE, namelen) == 0 &&
+            slot[IMM2_SIZE+namelen] == 0) break;
           slot += cd->name_entry_size;
           }



Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2016-10-06 17:49:48 UTC (rev 1666)
+++ code/trunk/testdata/testinput2    2016-10-13 16:00:48 UTC (rev 1667)
@@ -4243,4 +4243,8 @@


/\N(?(?C)0?!.)*/

+/(?<RA>abc)(?(R)xyz)/BZ
+
+/(?<R>abc)(?(R)xyz)/BZ
+
/-- End of testinput2 --/

Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2016-10-06 17:49:48 UTC (rev 1666)
+++ code/trunk/testdata/testoutput2    2016-10-13 16:00:48 UTC (rev 1667)
@@ -14670,4 +14670,32 @@
 /\N(?(?C)0?!.)*/
 Failed: assertion expected after (?( or (?(?C) at offset 4


+/(?<RA>abc)(?(R)xyz)/BZ
+------------------------------------------------------------------
+        Bra
+        CBra 1
+        abc
+        Ket
+        Cond
+        Cond recurse any
+        xyz
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+
+/(?<R>abc)(?(R)xyz)/BZ
+------------------------------------------------------------------
+        Bra
+        CBra 1
+        abc
+        Ket
+        Cond
+      1 Cond ref
+        xyz
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+
 /-- End of testinput2 --/