pp_hot.c: First letter of latin-1 classnames wasn't being checked correctly.
authorBrian Fraser <fraserbn@gmail.com>
Tue, 13 Dec 2011 22:32:48 +0000 (19:32 -0300)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 16 Dec 2011 04:13:28 +0000 (20:13 -0800)
Previously the first letter for latin-1 classnames was being mischecked, only
allowing ASCII, which caused an instance of the Unicode Bug for downgradable
classnames.

pp_hot.c
t/uni/package.t

index 70eb5a1..a2d6f91 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -2973,7 +2973,7 @@ S_method_common(pTHX_ SV* meth, U32* hashp)
            if (!packname ||
                ((UTF8_IS_START(*packname) && DO_UTF8(sv))
                    ? !isIDFIRST_utf8((U8*)packname)
-                   : !isIDFIRST(*packname)
+                   : !isIDFIRST_L1((U8)*packname)
                ))
            {
                Perl_croak(aTHX_ "Can't call method \"%"SVf"\" %s",
index 317ddd4..bb9092b 100644 (file)
@@ -6,7 +6,7 @@ BEGIN {
     require './test.pl';
 }
 
-plan (tests => 16);
+plan (tests => 18);
 
 use utf8;
 use open qw( :utf8 :std );
@@ -92,3 +92,20 @@ ok 1, "sanity check. If we got this far, UTF-8 in package names is legal.";
     eval q[package ᕘ {];
     like $@, qr/\AMissing right curly /, "comp/package_block.t test";
 }
+
+# perl #105922
+
+{
+   my $latin_1 = "þackage";
+   my $utf8    = "þackage";
+   utf8::downgrade($latin_1);
+   utf8::upgrade($utf8);
+
+   local $@;
+   eval { $latin_1->can("yadda") };
+   ok(!$@, "latin1->meth works");
+
+   local $@;
+   eval { $utf8->can("yadda") };
+   ok(!$@, "utf8->meth works");
+}