Fix bad compile of patterns like /[A-`]/i,utf where the range contains

characters with multiple other cases and the ranges adjoin.
This commit is contained in:
Philip.Hazel 2015-03-06 11:57:06 +00:00
parent 24a102885d
commit 54396a364d
6 changed files with 30 additions and 1 deletions

View File

@ -115,6 +115,11 @@ of various issues, and new ones are still appear unfortunately. To fix
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
-----------------------------

View File

@ -2864,7 +2864,11 @@ if ((options & PCRE2_CASELESS) != 0)
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);
}
}

3
testdata/testinput4 vendored
View File

@ -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

3
testdata/testinput5 vendored
View File

@ -1638,4 +1638,7 @@
/[^\xff]((?1))/utf,debug
/[A-`]/iB,utf
abcdefghijklmno
# End of testinput5

View File

@ -3735,4 +3735,8 @@ No match
\x{23a}\x{23a}\x{2c65}\x{23a}
No match
/[A-`]/i,utf
abcdefghijklmno
0: a
# End of testinput4

10
testdata/testoutput5 vendored
View File

@ -4009,4 +4009,14 @@ Subject length lower bound = 1
/[^\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