Control: tags -1 + confirmed Hi Heiko
On Mon, Nov 05, 2012 at 12:36:21PM +0100, Heiko Schlittermann wrote:
> Package: libarchive-zip-perl
> Version: 1.30-6
> Severity: normal
> Tags: upstream
>
> The manpage of Archive::Zip states:
>
> extractMemberWithoutPaths( $memberOrName [, $extractedName ] )
>
> Extract the given member, or match its name and extract it. Does not use
> path information
> (extracts into the current directory). Returns undef if member doesn't
> exist in this Zip. If
> optional second arg is given, use it as the name of the extracted member
> (its paths will be
> deleted too). Otherwise, the internal filename of the member (minus paths)
> is used as the name of
> the extracted file or directory. Returns "AZ_OK" on success.
>
> It's not true. If you pass a pathname as the second argument
>
> - the leading directories(!) are created (should be noted in the man
> page, as
> from my POV it's not common in the unix world.)
>
> - the pathname is used as the name for the extracted file
>
> The man page states, that paths will be removed too from the second
> argument.
>
> I'm not sure how to solve the problem. It could be fixed easily around
> line 202ff in Archive/Zip/Archive.pm, but I'd be afraid that this could
> break existing applications (at least mine ☺)
>
> Here is some code to reproduce the behaviour:
>
> #! /usr/bin/perl
> use 5.010;
> use strict;
> use warnings;
> use Archive::Zip;
>
> my $DIR = "/tmp/$$.d/Xtract/";
>
> my $zipfile = shift // die "need name of zip file\n";
> my $zip = new Archive::Zip $zipfile or die "Archive::Zip $zipfile: $!\n";
>
> foreach my $member ($zip->members) {
> say $member->fileName;
> $zip->extractMemberWithoutPaths($member, "$DIR/$name");
> }
>
> system "find $DIR/ -ls";
Thanks for your report. I tried to reproduce and it seems you are
coorect (btw, in your example there was a missing assignment for
$name?).
I have forwarded this upstream. *big* warning: I'm not sure if it's
enough with the attached patch already. I only did a quick look right
now.
Regards,
Salvatore
From c76a60f6c4d7c99e8796839d37896529360ef9c4 Mon Sep 17 00:00:00 2001 From: Salvatore Bonaccorso <[email protected]> Date: Sat, 24 Nov 2012 17:09:53 +0100 Subject: [PATCH] Strip paths in extractMemberWithoutPaths from member's names --- lib/Archive/Zip/Archive.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Archive/Zip/Archive.pm b/lib/Archive/Zip/Archive.pm index d9fd02e..358405c 100644 --- a/lib/Archive/Zip/Archive.pm +++ b/lib/Archive/Zip/Archive.pm @@ -217,9 +217,9 @@ sub extractMemberWithoutPaths { return AZ_OK if $member->isDirectory(); unless ($name) { $name = $member->fileName(); - $name =~ s{.*/}{}; # strip off directories, if any - $name = Archive::Zip::_asLocalName($name); } + $name =~ s{.*/}{}; # strip off directories, if any + $name = Archive::Zip::_asLocalName($name); my $rc = $member->extractToFileNamed( $name, @_ ); $member->{'compressedSize'} = $originalSize; return $rc; -- 1.7.10.4
signature.asc
Description: Digital signature

