[Pcre-svn] [956] code/trunk: Ignore qualifiers on lookaheads…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [956] code/trunk: Ignore qualifiers on lookaheads within lookbehinds when checking for a fixed
Revision: 956
          http://www.exim.org/viewvc/pcre2?view=rev&revision=956
Author:   ph10
Date:     2018-07-02 12:23:45 +0100 (Mon, 02 Jul 2018)
Log Message:
-----------
Ignore qualifiers on lookaheads within lookbehinds when checking for a fixed 
length.


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/src/pcre2_compile.c
    code/trunk/testdata/testinput1
    code/trunk/testdata/testinput2
    code/trunk/testdata/testoutput1
    code/trunk/testdata/testoutput2


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2018-07-02 10:54:03 UTC (rev 955)
+++ code/trunk/ChangeLog    2018-07-02 11:23:45 UTC (rev 956)
@@ -100,6 +100,10 @@
 "bumpalong" before there can be a match. The automatic "advance by one 
 character after an empty string match" rule is therefore inappropriate. A more 
 complicated algorithm has now been implemented.
+
+22. When checking to see if a lookbehind is of fixed length, lookaheads were 
+correctly ignored, but qualifiers on lookaheads were not being ignored, leading 
+to an incorrect "lookbehind assertion is not fixed length" error.



Version 10.31 12-February-2018

Modified: code/trunk/src/pcre2_compile.c
===================================================================
--- code/trunk/src/pcre2_compile.c    2018-07-02 10:54:03 UTC (rev 955)
+++ code/trunk/src/pcre2_compile.c    2018-07-02 11:23:45 UTC (rev 956)
@@ -8572,6 +8572,32 @@
     case META_LOOKAHEADNOT:
     pptr = parsed_skip(pptr + 1, PSKIP_KET);
     if (pptr == NULL) goto PARSED_SKIP_FAILED;
+    
+    /* Also ignore any qualifiers that follow a lookahead assertion. */
+    
+    switch (pptr[1])
+      {
+      case META_ASTERISK:
+      case META_ASTERISK_PLUS:
+      case META_ASTERISK_QUERY:   
+      case META_PLUS:
+      case META_PLUS_PLUS: 
+      case META_PLUS_QUERY:
+      case META_QUERY:
+      case META_QUERY_PLUS:
+      case META_QUERY_QUERY:       
+      pptr++;
+      break;
+      
+      case META_MINMAX:
+      case META_MINMAX_PLUS:
+      case META_MINMAX_QUERY:
+      pptr += 3;
+      break;
+      
+      default:
+      break;      
+      }
     break;


     /* Lookbehinds can be ignored, but must themselves be checked. */


Modified: code/trunk/testdata/testinput1
===================================================================
--- code/trunk/testdata/testinput1    2018-07-02 10:54:03 UTC (rev 955)
+++ code/trunk/testdata/testinput1    2018-07-02 11:23:45 UTC (rev 956)
@@ -6192,4 +6192,14 @@
 /(?<=\G.)/g,aftertext
     abc


+/(?<=(?=.)?)/
+
+/(?<=(?=.)?+)/
+
+/(?<=(?=.)*)/
+
+/(?<=(?=.){4,5})/
+
+/(?<=(?=.){4,5}x)/
+
# End of testinput1

Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2018-07-02 10:54:03 UTC (rev 955)
+++ code/trunk/testdata/testinput2    2018-07-02 11:23:45 UTC (rev 956)
@@ -5435,4 +5435,6 @@


/(?=a+)a(a+)++b/B

+/(?<=(?=.){4,5}x)/B
+
# End of testinput2

Modified: code/trunk/testdata/testoutput1
===================================================================
--- code/trunk/testdata/testoutput1    2018-07-02 10:54:03 UTC (rev 955)
+++ code/trunk/testdata/testoutput1    2018-07-02 11:23:45 UTC (rev 956)
@@ -9831,4 +9831,14 @@
  0: 
  0+ 


+/(?<=(?=.)?)/
+
+/(?<=(?=.)?+)/
+
+/(?<=(?=.)*)/
+
+/(?<=(?=.){4,5})/
+
+/(?<=(?=.){4,5}x)/
+
# End of testinput1

Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2018-07-02 10:54:03 UTC (rev 955)
+++ code/trunk/testdata/testoutput2    2018-07-02 11:23:45 UTC (rev 956)
@@ -16583,6 +16583,20 @@
         End
 ------------------------------------------------------------------


+/(?<=(?=.){4,5}x)/B
+------------------------------------------------------------------
+        Bra
+        AssertB
+        Reverse
+        Assert
+        Any
+        Ket
+        x
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+
 # End of testinput2
 Error -70: PCRE2_ERROR_BADDATA (unknown error number)
 Error -62: bad serialized data