34484a
From 7b3e03bd309fcc48a135123a60678ae2596b1c38 Mon Sep 17 00:00:00 2001
34484a
From: Tony Cook <tony@develop-help.com>
34484a
Date: Wed, 7 Jun 2017 15:00:26 +1000
34484a
Subject: [PATCH] clear the UTF8 flag on a glob if it isn't UTF8
34484a
MIME-Version: 1.0
34484a
Content-Type: text/plain; charset=UTF-8
34484a
Content-Transfer-Encoding: 8bit
34484a
34484a
Ported to 5.26.0:
34484a
34484a
commit 1097da16b21fe0a2257dba9937e55c0cca18f7e1
34484a
Author: Tony Cook <tony@develop-help.com>
34484a
Date:   Wed Jun 7 15:00:26 2017 +1000
34484a
34484a
    [perl #131263] clear the UTF8 flag on a glob if it isn't UTF8
34484a
34484a
    Previously sv_2pv_flags() would set the UTF8 flag on a glob if it
34484a
    had a UTF8 name, but wouldn't clear tha flag if it didn't.
34484a
34484a
    This meant a name change, eg. if assigned another glob, from a UTF8
34484a
    name to a non-UTF8 name would leave the flag set.
34484a
34484a
Signed-off-by: Petr Písař <ppisar@redhat.com>
34484a
---
34484a
 sv.c      |  2 ++
34484a
 t/op/gv.t | 10 +++++++++-
34484a
 2 files changed, 11 insertions(+), 1 deletion(-)
34484a
34484a
diff --git a/sv.c b/sv.c
34484a
index 9f3e28e..ae3dc95 100644
34484a
--- a/sv.c
34484a
+++ b/sv.c
34484a
@@ -3179,6 +3179,8 @@ Perl_sv_2pv_flags(pTHX_ SV *const sv, STRLEN *const lp, const I32 flags)
34484a
 	assert(SvPOK(buffer));
34484a
 	if (SvUTF8(buffer))
34484a
 	    SvUTF8_on(sv);
34484a
+        else
34484a
+            SvUTF8_off(sv);
34484a
 	if (lp)
34484a
 	    *lp = SvCUR(buffer);
34484a
 	return SvPVX(buffer);
34484a
diff --git a/t/op/gv.t b/t/op/gv.t
34484a
index 4fe6b00..670ccf6 100644
34484a
--- a/t/op/gv.t
34484a
+++ b/t/op/gv.t
34484a
@@ -12,7 +12,7 @@ BEGIN {
34484a
 
34484a
 use warnings;
34484a
 
34484a
-plan(tests => 280);
34484a
+plan(tests => 282);
34484a
 
34484a
 # type coercion on assignment
34484a
 $foo = 'foo';
34484a
@@ -1170,6 +1170,14 @@ SKIP: {
34484a
     is ($? & 127, 0,"[perl #128597] No crash when gp_free calls ckWARN_d");
34484a
 }
34484a
 
34484a
+{
34484a
+    # [perl #131263]
34484a
+    *sym = "\N{U+0080}";
34484a
+    ok(*sym eq "*main::\N{U+0080}", "utf8 flag properly set");
34484a
+    *sym = "\xC3\x80";
34484a
+    ok(*sym eq "*main::\xC3\x80", "utf8 flag properly cleared");
34484a
+}
34484a
+
34484a
 # test gv_try_downgrade()
34484a
 # If a GV can be stored in a stash in a compact, non-GV form, then
34484a
 # whenever ops are freed which reference the GV, an attempt is made to
34484a
-- 
34484a
2.9.4
34484a