[Pcre-svn] [986] code/trunk: Fix bad auto-possessification o…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [986] code/trunk: Fix bad auto-possessification of certain types of class.
Revision: 986
          http://www.exim.org/viewvc/pcre2?view=rev&revision=986
Author:   ph10
Date:     2018-08-17 15:45:35 +0100 (Fri, 17 Aug 2018)
Log Message:
-----------
Fix bad auto-possessification of certain types of class.


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/src/pcre2_auto_possess.c
    code/trunk/testdata/testinput4
    code/trunk/testdata/testoutput4


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2018-08-15 18:03:29 UTC (rev 985)
+++ code/trunk/ChangeLog    2018-08-17 14:45:35 UTC (rev 986)
@@ -160,7 +160,12 @@
 result of serializing is always the same. These fields are re-set when the 
 pattern is deserialized.


+35. In a pattern such as /[^\x{100}-\x{ffff}]*[\x80-\xff]/ which has a repeated
+negative class with no characters less than 0x100 followed by a positive class
+with only characters less than 0x100, the first class was incorrectly being
+auto-possessified, causing incorrect match failures.

+
Version 10.31 12-February-2018
------------------------------


Modified: code/trunk/src/pcre2_auto_possess.c
===================================================================
--- code/trunk/src/pcre2_auto_possess.c    2018-08-15 18:03:29 UTC (rev 985)
+++ code/trunk/src/pcre2_auto_possess.c    2018-08-17 14:45:35 UTC (rev 986)
@@ -505,7 +505,7 @@
   utf         TRUE in UTF mode
   cb          compile data block
   base_list   the data list of the base opcode
-  base_end    the end of the data list
+  base_end    the end of the base opcode
   rec_limit   points to recursion depth counter


 Returns:      TRUE if the auto-possessification is possible
@@ -730,7 +730,7 @@
       if ((*xclass_flags & XCL_MAP) == 0)
         {
         /* No bits are set for characters < 256. */
-        if (list[1] == 0) return TRUE;
+        if (list[1] == 0) return (*xclass_flags & XCL_NOT) == 0;
         /* Might be an empty repeat. */
         continue;
         }


Modified: code/trunk/testdata/testinput4
===================================================================
--- code/trunk/testdata/testinput4    2018-08-15 18:03:29 UTC (rev 985)
+++ code/trunk/testdata/testinput4    2018-08-17 14:45:35 UTC (rev 986)
@@ -2309,4 +2309,13 @@


# -------

+/[^\x{100}-\x{ffff}]*[\x80-\xff]/utf
+    \x{99}\x{99}\x{99}
+
+/[^\x{100}-\x{ffff}ABC]*[\x80-\xff]/utf
+    \x{99}\x{99}\x{99}
+
+/[^\x{100}-\x{ffff}]*[\x80-\xff]/i,utf
+    \x{99}\x{99}\x{99}
+
 # End of testinput4


Modified: code/trunk/testdata/testoutput4
===================================================================
--- code/trunk/testdata/testoutput4    2018-08-15 18:03:29 UTC (rev 985)
+++ code/trunk/testdata/testoutput4    2018-08-17 14:45:35 UTC (rev 986)
@@ -3730,4 +3730,16 @@


# -------

+/[^\x{100}-\x{ffff}]*[\x80-\xff]/utf
+    \x{99}\x{99}\x{99}
+ 0: \x{99}\x{99}\x{99}
+
+/[^\x{100}-\x{ffff}ABC]*[\x80-\xff]/utf
+    \x{99}\x{99}\x{99}
+ 0: \x{99}\x{99}\x{99}
+
+/[^\x{100}-\x{ffff}]*[\x80-\xff]/i,utf
+    \x{99}\x{99}\x{99}
+ 0: \x{99}\x{99}\x{99}
+
 # End of testinput4