2d50691
From 064604f904546ae4ddada5a2aa30256faccee39c Mon Sep 17 00:00:00 2001
2d50691
From: Tony Cook <tony@develop-help.com>
2d50691
Date: Wed, 7 Jun 2017 15:00:26 +1000
2d50691
Subject: [PATCH] clear the UTF8 flag on a glob if it isn't UTF8
2d50691
MIME-Version: 1.0
2d50691
Content-Type: text/plain; charset=UTF-8
2d50691
Content-Transfer-Encoding: 8bit
2d50691
2d50691
Ported to 5.24.1:
2d50691
2d50691
commit 1097da16b21fe0a2257dba9937e55c0cca18f7e1
2d50691
Author: Tony Cook <tony@develop-help.com>
2d50691
Date:   Wed Jun 7 15:00:26 2017 +1000
2d50691
2d50691
    [perl #131263] clear the UTF8 flag on a glob if it isn't UTF8
2d50691
2d50691
    Previously sv_2pv_flags() would set the UTF8 flag on a glob if it
2d50691
    had a UTF8 name, but wouldn't clear tha flag if it didn't.
2d50691
2d50691
    This meant a name change, eg. if assigned another glob, from a UTF8
2d50691
    name to a non-UTF8 name would leave the flag set.
2d50691
2d50691
Signed-off-by: Petr Písař <ppisar@redhat.com>
2d50691
---
2d50691
 sv.c      |  2 ++
2d50691
 t/op/gv.t | 10 +++++++++-
2d50691
 2 files changed, 11 insertions(+), 1 deletion(-)
2d50691
2d50691
diff --git a/sv.c b/sv.c
2d50691
index 12cbb5f..05584a2 100644
2d50691
--- a/sv.c
2d50691
+++ b/sv.c
2d50691
@@ -3162,6 +3162,8 @@ Perl_sv_2pv_flags(pTHX_ SV *const sv, STRLEN *const lp, const I32 flags)
2d50691
 	assert(SvPOK(buffer));
2d50691
 	if (SvUTF8(buffer))
2d50691
 	    SvUTF8_on(sv);
2d50691
+        else
2d50691
+            SvUTF8_off(sv);
2d50691
 	if (lp)
2d50691
 	    *lp = SvCUR(buffer);
2d50691
 	return SvPVX(buffer);
2d50691
diff --git a/t/op/gv.t b/t/op/gv.t
2d50691
index cdaaef5..ea79e51 100644
2d50691
--- a/t/op/gv.t
2d50691
+++ b/t/op/gv.t
2d50691
@@ -12,7 +12,7 @@ BEGIN {
2d50691
 
2d50691
 use warnings;
2d50691
 
2d50691
-plan(tests => 277 );
2d50691
+plan(tests => 279 );
2d50691
 
2d50691
 # type coercion on assignment
2d50691
 $foo = 'foo';
2d50691
@@ -1173,6 +1173,14 @@ SKIP: {
2d50691
 # [perl #131085] This used to crash; no ok() necessary.
2d50691
 $::{"A131085"} = sub {}; \&{"A131085"};
2d50691
 
2d50691
+{
2d50691
+    # [perl #131263]
2d50691
+    *sym = "\N{U+0080}";
2d50691
+    ok(*sym eq "*main::\N{U+0080}", "utf8 flag properly set");
2d50691
+    *sym = "\xC3\x80";
2d50691
+    ok(*sym eq "*main::\xC3\x80", "utf8 flag properly cleared");
2d50691
+}
2d50691
+
2d50691
 
2d50691
 __END__
2d50691
 Perl
2d50691
-- 
2d50691
2.9.4
2d50691