Fix compiling patterns with PCRE2_NO_AUTO_CAPTURE

This commit is contained in:
Petr Písař 2015-10-26 10:11:06 +01:00
parent 4c42ca60bd
commit 0e216e9ca6
2 changed files with 83 additions and 1 deletions

View File

@ -0,0 +1,75 @@
From fb774225c09cdb4848026167035596f502f28a5f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Mon, 26 Oct 2015 10:17:01 +0100
Subject: [PATCH] Fix PCRE2_NO_AUTO_CAPTURE bug
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Upstream commit ported to 10.20:
From 0536f51c8511921664d1dbfa7fbc156d0d687942 Mon Sep 17 00:00:00 2001
From: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Sun, 25 Oct 2015 17:35:34 +0000
Subject: [PATCH] Fix PCRE2_NO_AUTO_CAPTURE bug.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@393 6239d852-aaf2-0410-a92c-79f79f948069
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
src/pcre2_compile.c | 7 ++++---
testdata/testinput2 | 4 ++++
testdata/testoutput2 | 6 ++++++
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c
index 5d3584d..13febc9 100644
--- a/src/pcre2_compile.c
+++ b/src/pcre2_compile.c
@@ -3326,9 +3326,10 @@ for (; ptr < cb->end_pattern; ptr++)
if (ptr[1] != CHAR_QUESTION_MARK)
{
- if (ptr[1] != CHAR_ASTERISK &&
- (options & PCRE2_NO_AUTO_CAPTURE) == 0)
- cb->bracount++; /* Capturing group */
+ if (ptr[1] != CHAR_ASTERISK)
+ {
+ if ((options & PCRE2_NO_AUTO_CAPTURE) == 0) cb->bracount++;
+ }
else /* (*something) - just skip to closing ket */
{
ptr += 2;
diff --git a/testdata/testinput2 b/testdata/testinput2
index dc64019..35ebe47 100644
--- a/testdata/testinput2
+++ b/testdata/testinput2
@@ -4329,4 +4329,8 @@ a random value. /Ix
/^(o(\1{72}{\"{\\{00000059079}\d*){74}}){19}/I
+/((p(?'K/
+
+/((p(?'K/no_auto_capture
+
# End of testinput2
diff --git a/testdata/testoutput2 b/testdata/testoutput2
index cfc3ef0..3fdbc1f 100644
--- a/testdata/testoutput2
+++ b/testdata/testoutput2
@@ -14478,4 +14478,10 @@ Overall options: anchored
Last code unit = '}'
Subject length lower bound = 52629
+/((p(?'K/
+Failed: error 142 at offset 7: syntax error in subpattern name (missing terminator)
+
+/((p(?'K/no_auto_capture
+Failed: error 142 at offset 7: syntax error in subpattern name (missing terminator)
+
# End of testinput2
--
2.4.3

View File

@ -2,7 +2,7 @@
#%%global rcversion RC1
Name: pcre2
Version: 10.20
Release: %{?rcversion:0.}2%{?rcversion:.%rcversion}%{?dist}
Release: %{?rcversion:0.}3%{?rcversion:.%rcversion}%{?dist}
%global myversion %{version}%{?rcversion:-%rcversion}
Summary: Perl-compatible regular expression library
Group: System Environment/Libraries
@ -22,6 +22,9 @@ Patch1: pcre2-10.20-Fix-compiler-bug-for-classes-such-as-W-p-Any.patch
# Fix integer overflow for patterns whose minimum matching length is large,
# upstream bug #1699, fixed in upstream after 10.20.
Patch2: pcre2-10.20-Fix-integer-overflow-for-patterns-whose-minimum-matc.patch
# Fix compiling patterns with PCRE2_NO_AUTO_CAPTURE, upstream bug #1704,
# fixed in upstream after 10.20.
Patch3: pcre2-10.20-Fix-PCRE2_NO_AUTO_CAPTURE-bug.patch
# New libtool to get rid of RPATH and to use distribution autotools
BuildRequires: autoconf
@ -84,6 +87,7 @@ Utilities demonstrating PCRE2 capabilities like pcre2grep or pcre2test.
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
# Because of multilib patch
libtoolize --copy --force
autoreconf -vif
@ -162,6 +166,9 @@ make %{?_smp_mflags} check VERBOSE=yes
%{_mandir}/man1/pcre2test.*
%changelog
* Mon Oct 26 2015 Petr Pisar <ppisar@redhat.com> - 10.20-3
- Fix compiling patterns with PCRE2_NO_AUTO_CAPTURE (upstream bug #1704)
* Mon Oct 12 2015 Petr Pisar <ppisar@redhat.com> - 10.20-2
- Fix compiling classes with a negative escape and a property escape
(upstream bug #1697)