Package: perl
Version: 5.14.2-14
Severity: important
Tags: patch fixed-upstream
Forwarded: http://rt.perl.org/rt3/Public/Bug/Display.html?id=101710
perl -E 'my $x="br\x{f8}ndby"; $x =~ s/b/X/gi; say $x;' | od -c
gives the correct
0000000 X r 370 n d X y \n
on squeeze, but the incorrect
0000000 X r 370 n d b y \n
on wheezy.
This was fixed in 5.14.3 with the attached patch. As a regression from
squeeze, I think this is a candidate for wheezy if it's not too late
for that.
--
Niko Tyni [email protected]
>From 6e634c54a0f90c8878c8086142fe3451f8970a9e Mon Sep 17 00:00:00 2001
From: Karl Williamson <[email protected]>
Date: Tue, 1 Nov 2011 17:57:15 -0600
Subject: [PATCH] PATCH: [perl #101710] Regression with /i, latin1 chars.
The root cause of this bug is that it was assuming that a string was in
utf8 when it wasn't, and so was thinking that a byte was a starter byte
that wasn't, so was skipping ahead based on that starter byte.
---
pod/perldelta.pod | 8 ++++++++
regexec.c | 2 +-
t/re/pat.t | 9 ++++++++-
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index cdb8c83..1f1d4bd 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -307,6 +307,14 @@ L</Modules and Pragmata>.
XXX
+=item *
+
+A regression has been fixed that was introduced in 5.14, in C</i>
+regular expression matching, in which a match improperly fails if the
+pattern is in UTF-8, the target string is not, and a Latin-1 character
+precedes a character in the string that should match the pattern. [perl
+#101710]
+
=back
=head1 Known Problems
diff --git a/regexec.c b/regexec.c
index 0dc093f..2354be1 100644
--- a/regexec.c
+++ b/regexec.c
@@ -1521,7 +1521,7 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s,
{
goto got_it;
}
- s += UTF8SKIP(s);
+ s += (utf8_target) ? UTF8SKIP(s) : 1;
}
break;
case BOUNDL:
diff --git a/t/re/pat.t b/t/re/pat.t
index 4ef9663..4eb05c6 100644
--- a/t/re/pat.t
+++ b/t/re/pat.t
@@ -21,7 +21,7 @@ BEGIN {
require './test.pl';
}
-plan tests => 451; # Update this when adding/deleting tests.
+plan tests => 452; # Update this when adding/deleting tests.
run_tests() unless caller;
@@ -1167,6 +1167,13 @@ sub run_tests {
is($got,$want,'RT #84294: check that "ab" =~ /((\w+)(?{ push @got, $2 })){2}/ leaves @got in the correct state');
}
+
+ { # [perl #101710]
+ my $pat = "b";
+ utf8::upgrade($pat);
+ like("\xffb", qr/$pat/i, "/i: utf8 pattern, non-utf8 string, latin1-char preceding matching char in string");
+ }
+
} # End of sub run_tests
1;
--
1.7.10.4