-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Die when we try to write a packfile that we cannot read.
Currently the packfile format simply does not allow for the data it stores to contain a newline. Instead of allowing us to write a broken packfile and then find out later it is unreadable we throw an exception when we try to write. This is part of a response to Issue #8.
- Loading branch information
Showing
3 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use strict; | ||
use warnings; | ||
|
||
use Test::More; | ||
|
||
use ExtUtils::Packlist; | ||
use File::Temp qw( tempfile ); | ||
|
||
my $packlist = ExtUtils::Packlist->new(); | ||
|
||
my $evil_path = "/some/evil\npath"; | ||
my $packfile = tempfile; | ||
|
||
$packlist->{$evil_path} = { type => 'file' }; | ||
my $error; | ||
eval { | ||
$packlist->write($packfile); | ||
} or $error= $@; | ||
like($error,qr/Sorry/,"Got expected error"); | ||
|
||
if (0) { | ||
# in theory we should be able to pass this test, | ||
# in practice we die. I am leaving this here as a reminder. | ||
my $new_packlist = ExtUtils::Packlist->new($packfile); | ||
|
||
ok( exists $packlist->{$evil_path}, | ||
"Original path found in packlist before writing" ) | ||
or diag explain $packlist; | ||
|
||
ok( exists $new_packlist->{$evil_path}, | ||
"Original path found in packlist after reading" ) | ||
or diag explain $new_packlist; | ||
} | ||
|
||
done_testing; |