ppisar pushed to pcre (master). "Fix pcretest loop when \K is used in a lookbehind assertion"
notifications at fedoraproject.org
notifications at fedoraproject.org
Fri Apr 10 06:50:11 UTC 2015
>From 0583be6269724d1753425fd90409b4fecf857aaa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar at redhat.com>
Date: Fri, 10 Apr 2015 07:49:16 +0200
Subject: Fix pcretest loop when \K is used in a lookbehind assertion
diff --git a/pcre-8.36-Fix-pcretest-loop-for-K-in-lookbehind-assertion.patch b/pcre-8.36-Fix-pcretest-loop-for-K-in-lookbehind-assertion.patch
new file mode 100644
index 0000000..7183ff1
--- /dev/null
+++ b/pcre-8.36-Fix-pcretest-loop-for-K-in-lookbehind-assertion.patch
@@ -0,0 +1,175 @@
+From a690f6bf85225c34d3e336664d2437c16f7a7238 Mon Sep 17 00:00:00 2001
+From: ph10 <ph10 at 2f5784b3-3f2a-0410-8824-cb99058d5e15>
+Date: Tue, 7 Apr 2015 16:19:03 +0000
+Subject: [PATCH] Fix pcretest loop for \K in lookbehind assertion.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Upstream commit ported to 8.36:
+
+commit c3579a7581cb8b3ca3c9617d63083afea29de646
+Author: ph10 <ph10 at 2f5784b3-3f2a-0410-8824-cb99058d5e15>
+Date: Tue Apr 7 16:19:03 2015 +0000
+
+ Fix pcretest loop for \K in lookbehind assertion.
+
+ git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1544 2f5784b3-3f2a-0410-8824-cb99058d5e15
+
+Signed-off-by: Petr Písař <ppisar at redhat.com>
+---
+ pcretest.c | 30 +++++++++++++++++++++++++++---
+ testdata/testinput2 | 6 ++++++
+ testdata/testinput5 | 6 ++++++
+ testdata/testoutput2 | 28 ++++++++++++++++++++++++++++
+ testdata/testoutput5 | 28 ++++++++++++++++++++++++++++
+ 5 files changed, 95 insertions(+), 3 deletions(-)
+
+diff --git a/pcretest.c b/pcretest.c
+index b8dc3c6..6e6ef48 100644
+--- a/pcretest.c
++++ b/pcretest.c
+@@ -5618,9 +5618,33 @@ while (!done)
+ g_notempty = PCRE_NOTEMPTY_ATSTART | PCRE_ANCHORED;
+ }
+
+- /* For /g, update the start offset, leaving the rest alone */
+-
+- if (do_g) start_offset = use_offsets[1];
++ /* For /g, update the start offset, leaving the rest alone. There is a
++ tricky case when \K is used in a positive lookbehind assertion. This can
++ cause the end of the match to be less than or equal to the start offset.
++ In this case we restart at one past the start offset. This may return the
++ same match if the original start offset was bumped along during the
++ match, but eventually the new start offset will hit the actual start
++ offset. (In PCRE2 the true start offset is available, and this can be
++ done better. It is not worth doing more than making sure we do not loop
++ at this stage in the life of PCRE1.) */
++
++ if (do_g)
++ {
++ if (g_notempty == 0 && use_offsets[1] <= start_offset)
++ {
++ if (start_offset >= len) break; /* End of subject */
++ start_offset++;
++ if (use_utf)
++ {
++ while (start_offset < len)
++ {
++ if ((bptr[start_offset] & 0xc0) != 0x80) break;
++ start_offset++;
++ }
++ }
++ }
++ else start_offset = use_offsets[1];
++ }
+
+ /* For /G, update the pointer and length */
+
+diff --git a/testdata/testinput2 b/testdata/testinput2
+index 0fc535a..f8fbced 100644
+--- a/testdata/testinput2
++++ b/testdata/testinput2
+@@ -4088,4 +4088,10 @@ backtracking verbs. --/
+
+ "(?<=((?2))((?1)))"
+
++/(?<=\Ka)/g+
++ aaaaa
++
++/(?<=\Ka)/G+
++ aaaaa
++
+ /-- End of testinput2 --/
+diff --git a/testdata/testinput5 b/testdata/testinput5
+index e36b09d..fe7218d 100644
+--- a/testdata/testinput5
++++ b/testdata/testinput5
+@@ -790,4 +790,10 @@
+
+ /[b-d\x{200}-\x{250}]*[ae-h]?#[\x{200}-\x{250}]{0,8}[\x00-\xff]*#[\x{200}-\x{250}]+[a-z]/8BZ
+
++/(?<=\K\x{17f})/8g+
++ \x{17f}\x{17f}\x{17f}\x{17f}\x{17f}
++
++/(?<=\K\x{17f})/8G+
++ \x{17f}\x{17f}\x{17f}\x{17f}\x{17f}
++
+ /-- End of testinput5 --/
+diff --git a/testdata/testoutput2 b/testdata/testoutput2
+index 45662a9..5233de4 100644
+--- a/testdata/testoutput2
++++ b/testdata/testoutput2
+@@ -14221,4 +14221,32 @@ No match
+ "(?<=((?2))((?1)))"
+ Failed: lookbehind assertion is not fixed length at offset 17
+
++/(?<=\Ka)/g+
++ aaaaa
++ 0: a
++ 0+ aaaa
++ 0: a
++ 0+ aaaa
++ 0: a
++ 0+ aaa
++ 0: a
++ 0+ aa
++ 0: a
++ 0+ a
++ 0: a
++ 0+
++
++/(?<=\Ka)/G+
++ aaaaa
++ 0: a
++ 0+ aaaa
++ 0: a
++ 0+ aaa
++ 0: a
++ 0+ aa
++ 0: a
++ 0+ a
++ 0: a
++ 0+
++
+ /-- End of testinput2 --/
+diff --git a/testdata/testoutput5 b/testdata/testoutput5
+index 5c098e6..b338e23 100644
+--- a/testdata/testoutput5
++++ b/testdata/testoutput5
+@@ -1897,4 +1897,32 @@ Failed: disallowed Unicode code point (>= 0xd800 && <= 0xdfff) at offset 5
+ End
+ ------------------------------------------------------------------
+
++/(?<=\K\x{17f})/8g+
++ \x{17f}\x{17f}\x{17f}\x{17f}\x{17f}
++ 0: \x{17f}
++ 0+ \x{17f}\x{17f}\x{17f}\x{17f}
++ 0: \x{17f}
++ 0+ \x{17f}\x{17f}\x{17f}\x{17f}
++ 0: \x{17f}
++ 0+ \x{17f}\x{17f}\x{17f}
++ 0: \x{17f}
++ 0+ \x{17f}\x{17f}
++ 0: \x{17f}
++ 0+ \x{17f}
++ 0: \x{17f}
++ 0+
++
++/(?<=\K\x{17f})/8G+
++ \x{17f}\x{17f}\x{17f}\x{17f}\x{17f}
++ 0: \x{17f}
++ 0+ \x{17f}\x{17f}\x{17f}\x{17f}
++ 0: \x{17f}
++ 0+ \x{17f}\x{17f}\x{17f}
++ 0: \x{17f}
++ 0+ \x{17f}\x{17f}
++ 0: \x{17f}
++ 0+ \x{17f}
++ 0: \x{17f}
++ 0+
++
+ /-- End of testinput5 --/
+--
+2.1.0
+
diff --git a/pcre.spec b/pcre.spec
index 14bdc58..3d6c543 100644
--- a/pcre.spec
+++ b/pcre.spec
@@ -37,6 +37,9 @@ Patch8: pcre-8.36-Fix-stack-overflow-instead-of-diagnostic-for-mutual-.patch
# Fix pcregrep loop when \K is used in a lookbehind assertion, bug #1210423,
# in upstream after 8.36
Patch9: pcre-8.36-Fix-pcregrep-loop-when-K-is-used-in-a-lookbehind-ass.patch
+# Fix pcretest loop when \K is used in a lookbehind assertion, bug #1210423,
+# in upstream after 8.36
+Patch10: pcre-8.36-Fix-pcretest-loop-for-K-in-lookbehind-assertion.patch
BuildRequires: readline-devel
# New libtool to get rid of rpath
BuildRequires: autoconf, automake, libtool
@@ -86,6 +89,7 @@ Utilities demonstrating PCRE capabilities like pcregrep or pcretest.
%patch7 -p1 -b .parenthesized_comment
%patch8 -p1 -b .mutual_recursion_in_assertion
%patch9 -p1 -b .pcregrep_k_loop
+%patch10 -p1 -b .pcretest_k_loop
# Because of rpath patch
libtoolize --copy --force && autoreconf -vif
# One contributor's name is non-UTF-8
@@ -165,6 +169,7 @@ make %{?_smp_mflags} check VERBOSE=yes
- Fix compliation of mutual recursion inside a lookbehind assertion
(bug #1210417)
- Fix pcregrep loop when \K is used in a lookbehind assertion (bug #1210423)
+- Fix pcretest loop when \K is used in a lookbehind assertion (bug #1210423)
* Thu Mar 26 2015 Petr Pisar <ppisar at redhat.com> - 8.36-4
- Fix computing size of JIT read-only data (bug #1206131)
--
cgit v0.10.2
http://pkgs.fedoraproject.org/cgit/pcre.git/commit/?h=master&id=0583be6269724d1753425fd90409b4fecf857aaa
More information about the scm-commits
mailing list