Skip to content

Commit

Permalink
UTF8 encode appended file content
Browse files Browse the repository at this point in the history
Archive::Tar expects octets will corrupt the tar on perls 5.14+
when given a character string.
Both YAML and JSON (CPAN Meta) files should be in uf8 so this should be ok.
  • Loading branch information
rwstauner committed Sep 4, 2012
1 parent 488fcb7 commit 3106d9b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/Module/Faker/Dist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use File::Temp ();
use File::Path ();
use Parse::CPAN::Meta 1.4401;
use Path::Class;
use Encode qw( encode_utf8 );

has name => (is => 'ro', isa => 'Str', required => 1);
has version => (is => 'ro', isa => 'Maybe[Str]', default => '0.01');
Expand All @@ -23,7 +24,12 @@ has append => (is => 'ro', isa => 'ArrayRef[HashRef]', default => sub {[]}

sub append_for {
my ($self, $filename) = @_;
[ map { $_->{content} } grep { $filename eq $_->{file} } @{$self->append} ]
return [
# YAML and JSON should both be in utf8 (if not plain ascii)
map { encode_utf8($_->{content}) }
grep { $filename eq $_->{file} }
@{ $self->append }
];
}

has archive_basename => (
Expand Down

0 comments on commit 3106d9b

Please sign in to comment.