Skip to content

Commit

Permalink
Merge pull request #29 from haarg/mime-taint-5.8
Browse files Browse the repository at this point in the history
maintain taint flag when encoding MIME on old perl
  • Loading branch information
dankogai committed Jan 22, 2015
2 parents 8a77500 + f43da80 commit 4d9fd3a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Encode/MIME/Header.pm
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ sub encode($$;$) {
push @line, join( "\n " => @subline );
}
$_[1] = '' if $chk;
return join( "\n", @line );
return (substr($str, 0, 0) . join( "\n", @line ));
}

use constant HEAD => '=?UTF-8?';
Expand Down
5 changes: 3 additions & 2 deletions t/taint.t
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use strict;
use Encode qw(encode decode);
use Scalar::Util qw(tainted);
use Test::More;
my $str = "dan\x{5f3e}" . substr($ENV{PATH},0,0); # tainted string to encode
my $taint = substr($ENV{PATH},0,0);
my $str = "dan\x{5f3e}" . $taint; # tainted string to encode
my $bin = encode('UTF-8', $str); # tainted binary to decode
my @names = Encode->encodings(':all');
plan tests => 2 * @names;
Expand All @@ -16,7 +17,7 @@ for my $name (@names) {
skip $@, 1 if $@;
ok tainted($e), "encode $name";
}
$bin = $e if $e;
$bin = $e.$taint if $e;
eval {
$d = decode($name, $bin);
};
Expand Down

0 comments on commit 4d9fd3a

Please sign in to comment.