[Pcre-svn] [1741] code/trunk: Fix zero-repeat leading subrou…

Inizio della pagina
Delete this message
Autore: Subversion repository
Data:  
To: pcre-svn
Oggetto: [Pcre-svn] [1741] code/trunk: Fix zero-repeat leading subroutine call first character error.
Revision: 1741
          http://vcs.pcre.org/viewvc?view=rev&revision=1741
Author:   ph10
Date:     2018-10-20 10:38:44 +0100 (Sat, 20 Oct 2018)
Log Message:
-----------
Fix zero-repeat leading subroutine call first character error.


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/pcre_compile.c
    code/trunk/testdata/testinput1
    code/trunk/testdata/testoutput1


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2018-09-21 07:34:10 UTC (rev 1740)
+++ code/trunk/ChangeLog    2018-10-20 09:38:44 UTC (rev 1741)
@@ -40,7 +40,12 @@
 7. Fix subject buffer overread in JIT when UTF is disabled and \X or \R has
 a greater than 1 fixed quantifier. This issue was found by Yunho Kim.


+8. If a pattern started with a subroutine call that had a quantifier with a
+minimum of zero, an incorrect "match must start with this character" could be
+recorded. Example: /(?&xxx)*ABC(?<xxx>XYZ)/ would (incorrectly) expect 'A' to
+be the first character of a match.

+
Version 8.42 20-March-2018
--------------------------


Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c    2018-09-21 07:34:10 UTC (rev 1740)
+++ code/trunk/pcre_compile.c    2018-10-20 09:38:44 UTC (rev 1741)
@@ -7642,6 +7642,8 @@
         /* Can't determine a first byte now */


         if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
+        zerofirstchar = firstchar;
+        zerofirstcharflags = firstcharflags;
         continue;




Modified: code/trunk/testdata/testinput1
===================================================================
--- code/trunk/testdata/testinput1    2018-09-21 07:34:10 UTC (rev 1740)
+++ code/trunk/testdata/testinput1    2018-10-20 09:38:44 UTC (rev 1741)
@@ -5742,4 +5742,19 @@
 /X+(?#comment)?/
     >XXX<


+/   (?<word> \w+ )*    \.   /xi
+    pokus.
+    
+/(?(DEFINE) (?<word> \w+ ) ) (?&word)*   \./xi
+    pokus.
+
+/(?(DEFINE) (?<word> \w+ ) ) ( (?&word)* )   \./xi 
+    pokus.
+
+/(?&word)*  (?(DEFINE) (?<word> \w+ ) )  \./xi
+    pokus.
+
+/(?&word)*  \. (?<word> \w+ )/xi
+    pokus.hokus
+
 /-- End of testinput1 --/


Modified: code/trunk/testdata/testoutput1
===================================================================
--- code/trunk/testdata/testoutput1    2018-09-21 07:34:10 UTC (rev 1740)
+++ code/trunk/testdata/testoutput1    2018-10-20 09:38:44 UTC (rev 1741)
@@ -9446,4 +9446,28 @@
     >XXX<
  0: X


+/   (?<word> \w+ )*    \.   /xi
+    pokus.
+ 0: pokus.
+ 1: pokus
+    
+/(?(DEFINE) (?<word> \w+ ) ) (?&word)*   \./xi
+    pokus.
+ 0: pokus.
+
+/(?(DEFINE) (?<word> \w+ ) ) ( (?&word)* )   \./xi 
+    pokus.
+ 0: pokus.
+ 1: <unset>
+ 2: pokus
+
+/(?&word)*  (?(DEFINE) (?<word> \w+ ) )  \./xi
+    pokus.
+ 0: pokus.
+
+/(?&word)*  \. (?<word> \w+ )/xi
+    pokus.hokus
+ 0: pokus.hokus
+ 1: hokus
+
 /-- End of testinput1 --/