Skip to content

Commit 1097da1

Browse files
committed
[perl #131263] clear the UTF8 flag on a glob if it isn't UTF8
Previously sv_2pv_flags() would set the UTF8 flag on a glob if it had a UTF8 name, but wouldn't clear tha flag if it didn't. This meant a name change, eg. if assigned another glob, from a UTF8 name to a non-UTF8 name would leave the flag set.
1 parent 99b8476 commit 1097da1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

sv.c

+2
Original file line numberDiff line numberDiff line change
@@ -3185,6 +3185,8 @@ Perl_sv_2pv_flags(pTHX_ SV *const sv, STRLEN *const lp, const I32 flags)
31853185
assert(SvPOK(buffer));
31863186
if (SvUTF8(buffer))
31873187
SvUTF8_on(sv);
3188+
else
3189+
SvUTF8_off(sv);
31883190
if (lp)
31893191
*lp = SvCUR(buffer);
31903192
return SvPVX(buffer);

t/op/gv.t

+9-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ BEGIN {
1212

1313
use warnings;
1414

15-
plan(tests => 282);
15+
plan(tests => 284);
1616

1717
# type coercion on assignment
1818
$foo = 'foo';
@@ -1170,6 +1170,14 @@ SKIP: {
11701170
is ($? & 127, 0,"[perl #128597] No crash when gp_free calls ckWARN_d");
11711171
}
11721172

1173+
{
1174+
# [perl #131263]
1175+
*sym = "\N{U+0080}";
1176+
ok(*sym eq "*main::\N{U+0080}", "utf8 flag properly set");
1177+
*sym = "\xC3\x80";
1178+
ok(*sym eq "*main::\xC3\x80", "utf8 flag properly cleared");
1179+
}
1180+
11731181
# test gv_try_downgrade()
11741182
# If a GV can be stored in a stash in a compact, non-GV form, then
11751183
# whenever ops are freed which reference the GV, an attempt is made to

0 commit comments

Comments
 (0)