diff options
author | Rafael Garcia-Suarez <rgs@consttype.org> | 2010-03-09 11:06:43 +0100 |
---|---|---|
committer | Jesse Vincent <jesse@bestpractical.com> | 2010-05-13 17:59:23 -0400 |
commit | cbfe6b993239fc26ff053a2a8c22c2631a930d7e (patch) | |
tree | 1e87a91d3f8591fe0680312247d1fb127a8b8c69 | |
parent | 47cadbf5184ffeea1fd5457f8355ab6075226769 (diff) | |
download | perl-cbfe6b993239fc26ff053a2a8c22c2631a930d7e.tar.gz |
More backwards-compatible way to force loading of SWASHNEW in Safe
-rw-r--r-- | dist/Safe/Safe.pm | 2 | ||||
-rw-r--r-- | dist/Safe/t/safeutf8.t | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/dist/Safe/Safe.pm b/dist/Safe/Safe.pm index cc872802b1..59b59e8a48 100644 --- a/dist/Safe/Safe.pm +++ b/dist/Safe/Safe.pm @@ -66,7 +66,7 @@ require utf8; # and also loads the ToFold SWASH. # (Swashes are cached internally by perl in PL_utf8_* variables # independent of being inside/outside of Safe. So once loaded they can be) -do { my $unicode = pack('U',0xC4).'1a'; $unicode =~ /\xE4/i; }; +do { my $a = pack('U',0xC4); my $b = chr 0xE4; utf8::upgrade $b; $a =~ /$b/i }; # now we can safely include utf8::SWASHNEW in $default_share defined below. my $default_root = 0; diff --git a/dist/Safe/t/safeutf8.t b/dist/Safe/t/safeutf8.t index 28441da100..42b84ef788 100644 --- a/dist/Safe/t/safeutf8.t +++ b/dist/Safe/t/safeutf8.t @@ -16,12 +16,12 @@ use Opcode qw(full_opset); pass; my $safe = Safe->new('PLPerl'); -$safe->permit(qw(pack)); +$safe->deny_only(); # Expression that triggers require utf8 and call to SWASHNEW. # Fails with "Undefined subroutine PLPerl::utf8::SWASHNEW called" # if SWASHNEW is not shared, else returns true if unicode logic is working. -my $trigger = q{ my $a = pack('U',0xC4); $a =~ /\\xE4/i }; +my $trigger = q{ my $a = pack('U',0xC4); my $b = chr 0xE4; utf8::upgrade $b; $a =~ /$b/i }; ok $safe->reval( $trigger ), 'trigger expression should return true'; is $@, '', 'trigger expression should not die'; |