Fix parsing extended bracketed character classes

This commit is contained in:
Petr Písař 2018-04-20 12:09:33 +02:00
parent b8e600698b
commit 7d51eee368
2 changed files with 64 additions and 0 deletions

View File

@ -0,0 +1,57 @@
From 8121278aa8fe72e9e8aca8651c7f1d4fa204ac1d Mon Sep 17 00:00:00 2001
From: Karl Williamson <khw@cpan.org>
Date: Mon, 2 Apr 2018 21:54:59 -0600
Subject: [PATCH] PATCH: [perl #132167] Parse error in regex_sets
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
When popping the stack, the code inappropriately also subtracted one
from the result. This is probably left over from an earlier change in
the implementation. The top of the stack contained the correct value;
subtracting was a mistake.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
regcomp.c | 2 +-
t/re/regex_sets.t | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/regcomp.c b/regcomp.c
index 018d5646fc..39ab260efa 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -15689,7 +15689,7 @@ redo_curchar:
* fence. Get rid of it */
fence_ptr = av_pop(fence_stack);
assert(fence_ptr);
- fence = SvIV(fence_ptr) - 1;
+ fence = SvIV(fence_ptr);
SvREFCNT_dec_NN(fence_ptr);
fence_ptr = NULL;
diff --git a/t/re/regex_sets.t b/t/re/regex_sets.t
index e9644bd4e6..e70df81254 100644
--- a/t/re/regex_sets.t
+++ b/t/re/regex_sets.t
@@ -204,6 +204,17 @@ for my $char ("٠", "٥", "٩") {
like("a", qr/$pat/, "/$pat/ compiles and matches 'a'");
}
+{ # [perl #132167]
+ fresh_perl_is('no warnings "experimental::regex_sets";
+ print "c" =~ qr/(?[ ( \p{Uppercase} ) + (\p{Lowercase} - ([a] + [b])) ])/;',
+ 1, {},
+ 'qr/(?[ ( \p{Uppercase} ) + (\p{Lowercase} - ([a] + [b])) ]) compiles and properly matches');
+ fresh_perl_is('no warnings "experimental::regex_sets";
+ print "b" =~ qr/(?[ ( \p{Uppercase} ) + (\p{Lowercase} - ([a] + [b])) ])/;',
+ "", {},
+ 'qr/(?[ ( \p{Uppercase} ) + (\p{Lowercase} - ([a] + [b])) ]) compiles and properly matches');
+}
+
done_testing();
1;
--
2.14.3

View File

@ -263,6 +263,10 @@ Patch81: perl-5.27.8-don-t-clobber-file-bytes-in-encoding-layer.patch
# Fix line numbers in multi-line s///, RT#131930, in upstream after 5.27.9
Patch82: perl-5.27.9-fix-line-numbers-in-multi-line-s.patch
# Fix parsing extended bracketed character classes, RT#132167,
# in upstream after 5.27.10
Patch83: perl-5.27.10-PATCH-perl-132167-Parse-error-in-regex_sets.patch
# Link XS modules to libperl.so with EU::CBuilder on Linux, bug #960048
Patch200: perl-5.16.3-Link-XS-modules-to-libperl.so-with-EU-CBuilder-on-Li.patch
@ -2866,6 +2870,7 @@ Perl extension for Version Objects
%patch80 -p1
%patch81 -p1
%patch82 -p1
%patch83 -p1
%patch200 -p1
%patch201 -p1
@ -2916,6 +2921,7 @@ perl -x patchlevel.h \
'Fedora Patch80: Fix parsing braced subscript after parentheses (RT#8045)' \
'Fedora Patch81: Do not clobber file bytes in :encoding layer (RT#132833)' \
'Fedora Patch82: Fix line numbers in multi-line s/// (RT#131930)' \
'Fedora Patch83: Fix parsing extended bracketed character classes (RT#132167)' \
'Fedora Patch200: Link XS modules to libperl.so with EU::CBuilder on Linux' \
'Fedora Patch201: Link XS modules to libperl.so with EU::MM on Linux' \
%{nil}
@ -5208,6 +5214,7 @@ popd
(bug #1557667)
- Do not clobber file bytes in :encoding layer (RT#132833)
- Fix line numbers in multi-line s/// (RT#131930)
- Fix parsing extended bracketed character classes (RT#132167)
* Mon Apr 16 2018 Petr Pisar <ppisar@redhat.com> - 4:5.26.2-411
- 5.26.2 bump