Skip to content

Commit b64bec8

Browse files
committed
cpan/Archive-Tar - Update to version 3.04
3.04 25/02/2025 (Dan Church, Arne Johannessen && SISYPHUS) - Fix handling filenames with trailing whitespace - Allow --format=ustar option for ptar - GH#21402 Symlink tests on Windows 3.02 13/04/2023 (Manfred Stock) - Test block sizes up to (2**31 - 1) bytes only (fix for 32bit perls) - Don't match on message from exception in symlink test - Improve formatting of $Archive::Tar::RESOLVE_SYMLINK documentation
1 parent 30aeaad commit b64bec8

File tree

10 files changed

+174
-23
lines changed

10 files changed

+174
-23
lines changed

MANIFEST

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ cpan/Archive-Tar/t/05_iter.t Archive::Tar tests
233233
cpan/Archive-Tar/t/06_error.t Archive::Tar tests
234234
cpan/Archive-Tar/t/08_ptargrep.t Test file related to Archive::Tar
235235
cpan/Archive-Tar/t/09_roundtrip.t Test file related to Archive::Tar
236+
cpan/Archive-Tar/t/10_ptar.t Archive-Tar
237+
cpan/Archive-Tar/t/90_symlink.t Archive-Tar
236238
cpan/Archive-Tar/t/99_pod.t Archive::Tar tests
237239
cpan/Archive-Tar/t/src/header/signed.tar Archive::Tar tests
238240
cpan/Archive-Tar/t/src/linktest/linktest_missing_dir.tar Archive::Tar tests

Porting/Maintainers.pl

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,16 @@ package Maintainers;
129129
our %Modules = (
130130

131131
'Archive::Tar' => {
132-
'DISTRIBUTION' => 'BINGOS/Archive-Tar-3.02.tar.gz',
133-
'SYNCINFO' => 'jkeenan on Tue Dec 5 07:32:24 2023',
132+
'DISTRIBUTION' => 'BINGOS/Archive-Tar-3.04.tar.gz',
133+
'SYNCINFO' => 'mauke on Wed Mar 19 06:05:25 2025',
134134
'FILES' => q[cpan/Archive-Tar],
135135
'BUGS' => '[email protected]',
136136
'EXCLUDED' => [
137-
qw(t/07_ptardiff.t),
138-
qr{t/src/(long|short)/foo.txz},
139-
qw(t/90_symlink.t),
140-
],
141-
'CUSTOMIZED' => [
142-
'lib/Archive/Tar.pm',
143-
'lib/Archive/Tar/Constant.pm',
144-
'lib/Archive/Tar/File.pm',
137+
qw(
138+
t/07_ptardiff.t
139+
t/src/long/foo.txz
140+
t/src/short/foo.txz
141+
)
145142
],
146143
},
147144

cpan/Archive-Tar/bin/ptar

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ use Getopt::Std;
88
use Archive::Tar;
99
use Data::Dumper;
1010

11+
# Allow (and ignore) --format=ustar, for compatibility with GNU tar
12+
for (my $i = 0; $i < @ARGV; ++$i) {
13+
last if $ARGV[$i] eq '--';
14+
splice @ARGV, $i--, 1 if $ARGV[$i] eq '--format=ustar';
15+
splice @ARGV, $i--, 2 if $i < $#ARGV
16+
&& $ARGV[$i] eq '--format' && $ARGV[$i + 1] eq 'ustar';
17+
}
18+
1119
# Allow historic support for dashless bundled options
1220
# tar cvf file.tar
1321
# is valid (GNU) tar style

cpan/Archive-Tar/lib/Archive/Tar.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use vars qw[$DEBUG $error $VERSION $WARN $FOLLOW_SYMLINK $CHOWN $CHMOD
3232
$DEBUG = 0;
3333
$WARN = 1;
3434
$FOLLOW_SYMLINK = 0;
35-
$VERSION = "3.02_001";
35+
$VERSION = "3.04";
3636
$CHOWN = 1;
3737
$CHMOD = 1;
3838
$SAME_PERMISSIONS = $> == 0 ? 1 : 0;

cpan/Archive-Tar/lib/Archive/Tar/Constant.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use vars qw[$VERSION @ISA @EXPORT];
88
BEGIN {
99
require Exporter;
1010

11-
$VERSION = '3.02_001';
11+
$VERSION = '3.04';
1212
@ISA = qw[Exporter];
1313

1414
require Time::Local if $^O eq "MacOS";

cpan/Archive-Tar/lib/Archive/Tar/File.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use Archive::Tar::Constant;
1111

1212
use vars qw[@ISA $VERSION];
1313
#@ISA = qw[Archive::Tar];
14-
$VERSION = '3.02_001';
14+
$VERSION = '3.04';
1515

1616
### set value to 1 to oct() it during the unpack ###
1717

@@ -259,7 +259,7 @@ sub _new_from_file {
259259
unless ($type == DIR ) {
260260
my $fh = IO::File->new;
261261

262-
unless( $fh->open($path) ) {
262+
unless( $fh->open($path, 'r') ) {
263263
### dangling symlinks are fine, stop reading but continue
264264
### creating the object
265265
last READ if $type == SYMLINK;

cpan/Archive-Tar/t/04_resolved_issues.t

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,17 +269,25 @@ if ($^O ne 'msys') # symlink tests fail on Windows/msys2
269269

270270
### bug 103279
271271
### retain trailing whitespace on filename
272-
{
272+
SKIP: {
273273
ok( 1, "Testing bug 103279" );
274274
my $tar = $Class->new;
275275
isa_ok( $tar, $Class, " Object" );
276-
ok( $tar->add_data( 'white_space ', '' ),
276+
ok( open my $fh, '>', 'white_space ' );
277+
ok( close $fh );
278+
if (-e 'white_space' && $^O eq 'MSWin32') {
279+
# Creating a file under Windows using a name with trailing whitespace
280+
# sometimes results in the created filename being stripped of that
281+
# whitespace. I.e. open './foo ' -> creates './foo'.
282+
# This is known to only happen with *some* versions of Perl for
283+
# Windows, so we must test.
284+
skip 'Windows tries to be clever', 1;
285+
}
286+
ok( $tar->add_files( 'white_space ' ),
277287
" Add file <white_space > containing filename with trailing whitespace");
288+
ok( unlink 'white_space ' );
278289
ok( $tar->extract(), " Extract filename with trailing whitespace" );
279-
SKIP: {
280-
skip "Windows tries to be clever", 1 if $^O eq 'MSWin32';
281-
ok( ! -e 'white_space', " <white_space> should not exist" );
282-
}
290+
ok( ! -e 'white_space', " <white_space> should not exist" );
283291
ok( -e 'white_space ', " <white_space > should exist" );
284292
unlink foreach ('white_space ', 'white_space');
285293
}

cpan/Archive-Tar/t/10_ptar.t

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
use strict;
2+
use warnings;
3+
use Test::More;
4+
5+
use File::Spec;
6+
use FindBin '$Bin';
7+
use Archive::Tar;
8+
9+
# File names
10+
my $tartest = File::Spec->catfile("t", "ptar");
11+
my $foo = File::Spec->catfile("t", "ptar", "foo");
12+
my $tarfile = File::Spec->catfile("t", "ptar.tar");
13+
my $ptar = File::Spec->catfile($Bin, "..", "bin", "ptar");
14+
my $cmd = "$^X $ptar";
15+
16+
plan tests => 11;
17+
my $out;
18+
19+
# Create directory/files
20+
mkdir $tartest;
21+
open my $fh, ">", $foo or die $!;
22+
print $fh "file foo\n";
23+
close $fh;
24+
25+
# Create archive, dashless options
26+
$out = qx{$cmd cvf $tarfile $foo};
27+
is($?, 0, "create ok");
28+
cmp_ok($out, '=~', qr{foo}, "added foo to archive");
29+
30+
# List contents, -f option first
31+
$out = qx{$cmd -f $tarfile -t};
32+
is($?, 0, "list ok");
33+
cmp_ok($out, '=~', qr{foo}, "foo is in archive");
34+
35+
# Extract contents, no space after -f option
36+
unlink $foo or die $!;
37+
$out = qx{$cmd -x -f$tarfile};
38+
is($?, 0, "extract ok");
39+
is($out, "", "extract silent");
40+
ok(-e $foo, "extracted foo from archive");
41+
42+
# Create archive with --format=ustar, bundled options
43+
$out = qx{$cmd --format=ustar -cf $tarfile $foo};
44+
is($?, 0, "--format=ustar ignored ok");
45+
is($out, "", "--format=ustar ignored silently");
46+
47+
# Create archive with --format ustar
48+
$out = qx{$cmd -c -f $tarfile --format ustar $foo};
49+
is($?, 0, "--format ustar ignored ok");
50+
is($out, "", "--format ustar ignored silently");
51+
52+
# Cleanup
53+
END {
54+
unlink $tarfile or die $!;
55+
unlink $foo or die $!;
56+
rmdir $tartest or die $!;
57+
}

cpan/Archive-Tar/t/90_symlink.t

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
BEGIN { chdir 't' if -d 't' }
2+
3+
use lib '../lib';
4+
5+
use strict;
6+
use File::Spec;
7+
use File::Path;
8+
use Test::More;
9+
use Config;
10+
11+
my $win32_symlink_enabled = 0;
12+
13+
if($^O =~ /MSWin32/i && $Config{d_symlink}) {
14+
# Creation of symlinks is available to this system,
15+
# but might not have been enabled. We check on this
16+
# by checking whether symlink() actually works.
17+
18+
if(-e '../Makefile.PL') {
19+
symlink '../Makefile.PL', 'make.sym';
20+
if(-e 'make.sym') {
21+
$win32_symlink_enabled = 1;
22+
unlink 'make.sym';
23+
}
24+
}
25+
else {
26+
warn "Cannot establish whether symlink() is enabled as Makefile.PL was not found";
27+
$win32_symlink_enabled = 1; # We have no reason to assume otherwise.
28+
}
29+
}
30+
31+
### developer tests mostly
32+
if (($^O !~ /(linux|bsd|darwin|solaris|hpux|aix|
33+
sunos|dynixptx|haiku|irix|next|dec_osf|svr4|sco_sv|unicos|
34+
cygwin)/x and !$Config{d_symlink})
35+
||
36+
($^O =~ /MSWin/i and !$win32_symlink_enabled)) {
37+
plan skip_all => "Skipping tests on this platform";
38+
}
39+
plan 'no_plan';
40+
41+
my $Class = 'Archive::Tar';
42+
my $Dir = File::Spec->catdir( qw[src linktest] );
43+
my %Map = (
44+
File::Spec->catfile( $Dir, "linktest_with_dir.tar" ) => [
45+
[ 0, qr/SECURE EXTRACT MODE/ ],
46+
[ 1, qr/^$/ ]
47+
],
48+
File::Spec->catfile( $Dir, "linktest_missing_dir.tar" ) => [
49+
[ 0, qr/SECURE EXTRACT MODE/ ],
50+
[ 0, qr/Could not create directory/ ],
51+
],
52+
);
53+
54+
use_ok( $Class );
55+
56+
{ while( my($file, $aref) = each %Map ) {
57+
58+
for my $mode ( 0, 1 ) {
59+
my $expect = $aref->[$mode]->[0];
60+
my $regex = $aref->[$mode]->[1];
61+
62+
my $tar = $Class->new( $file );
63+
ok( $tar, "Object created from $file" );
64+
65+
### damn warnings
66+
local $Archive::Tar::INSECURE_EXTRACT_MODE = $mode;
67+
local $Archive::Tar::INSECURE_EXTRACT_MODE = $mode;
68+
69+
ok( 1, " Extracting with insecure mode: $mode" );
70+
71+
my $warning;
72+
local $SIG{__WARN__} = sub { $warning .= "@_" };
73+
74+
my $rv = eval { $tar->extract } || 0;
75+
ok( !$@, " No fatal error" );
76+
is( !!$rv, !!$expect, " RV as expected" );
77+
like( $warning, $regex, " Error matches $regex" );
78+
79+
rmtree( 'linktest' );
80+
}
81+
}
82+
}

t/porting/customized.dat

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# Regenerate this file using:
22
# cd t
33
# ./perl -I../lib porting/customized.t --regen
4-
Archive::Tar cpan/Archive-Tar/lib/Archive/Tar.pm a70653aff3a1e73c97c744c0b8dda93f0d54945a
5-
Archive::Tar cpan/Archive-Tar/lib/Archive/Tar/Constant.pm 9028a0094e8ad49f5b60d40166e82e46bd899a18
6-
Archive::Tar cpan/Archive-Tar/lib/Archive/Tar/File.pm 50bae89650d3567e54a5944c93bae47e9cb3313e
74
AutoLoader cpan/AutoLoader/t/02AutoSplit.t bb90cda13b88599ad45de4b45799d5218afcb6d8
85
ExtUtils::Constant cpan/ExtUtils-Constant/lib/ExtUtils/Constant/Base.pm 7560e1018f806db5689dee78728ccb8374aea741
96
ExtUtils::Constant cpan/ExtUtils-Constant/t/Constant.t 165e9c7132b003fd192d32a737b0f51f9ba4999e

0 commit comments

Comments
 (0)