Revision: 215
http://www.exim.org/viewvc/pcre2?view=rev&revision=215
Author: ph10
Date: 2015-03-06 11:57:06 +0000 (Fri, 06 Mar 2015)
Log Message:
-----------
Fix bad compile of patterns like /[A-`]/i,utf where the range contains
characters with multiple other cases and the ranges adjoin.
Modified Paths:
--------------
code/trunk/ChangeLog
code/trunk/src/pcre2_compile.c
code/trunk/testdata/testinput4
code/trunk/testdata/testinput5
code/trunk/testdata/testoutput4
code/trunk/testdata/testoutput5
Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog 2015-03-06 07:57:23 UTC (rev 214)
+++ code/trunk/ChangeLog 2015-03-06 11:57:06 UTC (rev 215)
@@ -115,7 +115,12 @@
existing and future issues, size computation is eliminated from the code,
and replaced by on-demand memory allocation.
+25. A pattern such as /(?i)[A-`]/, where characters in the other case are
+adjacent to the end of the range, and the range contained characters with more
+than one other case, caused incorrect behaviour when compiled in UTF mode. In
+that example, the range a-j was left out of the class.
+
Version 10.00 05-January-2015
-----------------------------
Modified: code/trunk/src/pcre2_compile.c
===================================================================
--- code/trunk/src/pcre2_compile.c 2015-03-06 07:57:23 UTC (rev 214)
+++ code/trunk/src/pcre2_compile.c 2015-03-06 11:57:06 UTC (rev 215)
@@ -2864,7 +2864,11 @@
range. Otherwise, use a recursive call to add the additional range. */
else if (oc < start && od >= start - 1) start = oc; /* Extend downwards */
- else if (od > end && oc <= end + 1) end = od; /* Extend upwards */
+ else if (od > end && oc <= end + 1)
+ {
+ end = od; /* Extend upwards */
+ if (end > classbits_end) classbits_end = (end <= 0xff ? end : 0xff);
+ }
else n8 += add_to_class(classbits, uchardptr, options, cb, oc, od);
}
}
Modified: code/trunk/testdata/testinput4
===================================================================
--- code/trunk/testdata/testinput4 2015-03-06 07:57:23 UTC (rev 214)
+++ code/trunk/testdata/testinput4 2015-03-06 11:57:06 UTC (rev 215)
@@ -2216,4 +2216,7 @@
\x{23a}\x{2c65}\x{2c65}\x{2c65}
\x{23a}\x{23a}\x{2c65}\x{23a}
+/[A-`]/i,utf
+ abcdefghijklmno
+
# End of testinput4
Modified: code/trunk/testdata/testinput5
===================================================================
--- code/trunk/testdata/testinput5 2015-03-06 07:57:23 UTC (rev 214)
+++ code/trunk/testdata/testinput5 2015-03-06 11:57:06 UTC (rev 215)
@@ -1640,4 +1640,7 @@
/[^\xff]((?1))/utf,debug
+/[A-`]/iB,utf
+ abcdefghijklmno
+
# End of testinput5
Modified: code/trunk/testdata/testoutput4
===================================================================
--- code/trunk/testdata/testoutput4 2015-03-06 07:57:23 UTC (rev 214)
+++ code/trunk/testdata/testoutput4 2015-03-06 11:57:06 UTC (rev 215)
@@ -3735,4 +3735,8 @@
\x{23a}\x{23a}\x{2c65}\x{23a}
No match
+/[A-`]/i,utf
+ abcdefghijklmno
+ 0: a
+
# End of testinput4
Modified: code/trunk/testdata/testoutput5
===================================================================
--- code/trunk/testdata/testoutput5 2015-03-06 07:57:23 UTC (rev 214)
+++ code/trunk/testdata/testoutput5 2015-03-06 11:57:06 UTC (rev 215)
@@ -4011,4 +4011,14 @@
/[^\xff]((?1))/utf,debug
Failed: error 140 at offset 11: recursion could loop indefinitely
+/[A-`]/iB,utf
+------------------------------------------------------------------
+ Bra
+ [A-z\x{212a}\x{17f}]
+ Ket
+ End
+------------------------------------------------------------------
+ abcdefghijklmno
+ 0: a
+
# End of testinput5