From: SADAHIRO Tomoyuki Date: Sat, 22 May 2004 21:38:33 +0000 (+0900) Subject: Re: utf-8 and taint don't work together X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f5cee72b6610421c22d816640f267c5b45b0450e;p=p5sagit%2Fp5-mst-13.2.git Re: utf-8 and taint don't work together Date: Sat, 22 May 2004 21:38:33 +0900 Message-Id: <20040522212704.C068.BQW10602@nifty.com> Date: Sun, 23 May 2004 09:56:15 +0900 Message-Id: <20040523095609.E404.BQW10602@nifty.com> p4raw-id: //depot/perl@22842 --- diff --git a/ext/Encode/lib/Encode/CN/HZ.pm b/ext/Encode/lib/Encode/CN/HZ.pm index 15440a4..dc4f54e 100644 --- a/ext/Encode/lib/Encode/CN/HZ.pm +++ b/ext/Encode/lib/Encode/CN/HZ.pm @@ -3,7 +3,7 @@ package Encode::CN::HZ; use strict; use vars qw($VERSION); -$VERSION = do { my @r = (q$Revision: 2.0 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +$VERSION = '2.00_01'; use Encode qw(:fallbacks); @@ -151,7 +151,8 @@ sub encode($$;$) $ret .= pack 'a*', $tmp; # remove UTF8 flag. } elsif ($str =~ s/(.)//) { - my $tmp = $GB->encode($1, $chk); + my $s = $1; + my $tmp = $GB->encode($s, $chk); last if !defined $tmp; if (length $tmp == 2) { # maybe a valid GB char (XXX) if ($in_ascii) { diff --git a/ext/Encode/lib/Encode/Unicode/UTF7.pm b/ext/Encode/lib/Encode/Unicode/UTF7.pm index a91bff7..4a80a5a 100644 --- a/ext/Encode/lib/Encode/Unicode/UTF7.pm +++ b/ext/Encode/lib/Encode/Unicode/UTF7.pm @@ -6,7 +6,7 @@ use strict; no warnings 'redefine'; use base qw(Encode::Encoding); __PACKAGE__->Define('UTF-7'); -our $VERSION = do { my @r = (q$Revision: 2.0 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +our $VERSION = '2.00_01'; use MIME::Base64; use Encode; @@ -38,7 +38,8 @@ sub encode($$;$){ if ($1 eq "+"){ $bytes .= "+-"; }else{ - my $base64 = encode_base64($e_utf16->encode($1), ''); + my $s = $1; + my $base64 = encode_base64($e_utf16->encode($s), ''); $base64 =~ s/=+$//; $bytes .= "+$base64-"; } diff --git a/sv.c b/sv.c index d776e15..ab21d76 100644 --- a/sv.c +++ b/sv.c @@ -3936,18 +3936,15 @@ Perl_sv_utf8_upgrade_flags(pTHX_ register SV *sv, I32 flags) U8 *s, *t, *e; int hibit = 0; - if (!sv) - return 0; - if (!SvPOK(sv)) { STRLEN len = 0; - (void) sv_2pv_flags(sv,&len, flags); - if (!SvPOK(sv)) - return len; + (void) SvPV_force(sv,len); } - if (SvUTF8(sv)) + if (SvUTF8(sv)) { + SvSETMAGIC(sv); return SvCUR(sv); + } if (SvIsCOW(sv)) { sv_force_normal_flags(sv, 0); @@ -3982,6 +3979,7 @@ Perl_sv_utf8_upgrade_flags(pTHX_ register SV *sv, I32 flags) /* Mark as UTF-8 even if no hibit - saves scanning loop */ SvUTF8_on(sv); } + SvSETMAGIC(sv); return SvCUR(sv); }