Discussion:
[rt.cpan.org #88297] -M crashes pp if option contains backslashes
(too old to reply)
Roderich Schupp via RT
2013-09-02 13:04:15 UTC
Permalink
Mon Sep 02 09:04:14 2013: Request 88297 was acted upon.
Transaction: Correspondence added by RSCHUPP
Queue: PAR-Packer
Subject: -M crashes pp if option contains backslashes
Broken in: 1.014
Severity: (no value)
Owner: RSCHUPP
Requestors: ***@cpan.org
Status: new
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=88297 >
I can reproduce the failure, but this command is kinda pointless:
it would result in path\to\my\Lib.pm being packed as module path::to::my::Lib
which is probably not want you want. And if you wanted it,
why not say -M path::to::my::Lib?
... Then when it
called $zip->member($in), the member with the given name didn't exist.
I'm including a patch to fix this
Your patch only pampers over the problem.
Also it's very bad style to modify the parameters ($in in this case)
of a function (except when it's to provide a default value).
The formulation in the original code is also lacking, though:
addString and addFile already return an Archive::Zip::Member object,
so why not use this to set compression options etc.

I applied the attached fix instead, will be in the next release of PAR::Packer.

Cheers, Roderich
Nathan Gary Glenn via RT
2013-09-02 18:12:39 UTC
Permalink
Mon Sep 02 14:12:38 2013: Request 88297 was acted upon.
Transaction: Correspondence added by NGLENN
Queue: PAR-Packer
Subject: -M crashes pp if option contains backslashes
Broken in: 1.014
Severity: (no value)
Owner: RSCHUPP
Requestors: ***@cpan.org
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=88297 >


Thanks for the tips, and for the quick fix!
Nathan Gary Glenn via RT
2013-09-02 19:26:21 UTC
Permalink
Mon Sep 02 15:26:20 2013: Request 88297 was acted upon.
Transaction: Correspondence added by NGLENN
Queue: PAR-Packer
Subject: -M crashes pp if option contains backslashes
Broken in: 1.014
Severity: (no value)
Owner: RSCHUPP
Requestors: ***@cpan.org
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=88297 >


Sorry to bring this up again. Just in the way of documentation, executing pp the way I did still results in an error later on. If somebody gets the following error the first time they run their executable (and not subsequent times), it is because they used the -M option incorrectly (the way I did):
mkdir C:\Users\...\AppData\Local\Temp\par-xyz\cache-abc/inc/lib/C:/: Invalid argument; The filename, directory name, or volume label syntax is incorrect at C:/strawberry/perl/vendor/lib/Archive/Zip/Archive.pm line 192.

This is purely due to user error, but a fail-fast mechanism might be useful. Otherwise, this will at least be a web search result.
Roderich Schupp via RT
2013-09-03 06:44:49 UTC
Permalink
Tue Sep 03 02:44:48 2013: Request 88297 was acted upon.
Transaction: Correspondence added by RSCHUPP
Queue: PAR-Packer
Subject: -M crashes pp if option contains backslashes
Broken in: 1.014
Severity: (no value)
Owner: RSCHUPP
Requestors: ***@cpan.org
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=88297 >
Post by Nathan Gary Glenn via RT
This is purely due to user error, but a fail-fast mechanism might be useful.
Maybe we could check whether -M was given an absolute pathname
and at least print a warning. Even on *nix, an absolute pathname
would probably not do what you wanted (though it would not result
in an outright error).

Cheers, Roderich
Nathan Gary Glenn via RT
2013-09-16 20:49:14 UTC
Permalink
Mon Sep 16 16:49:13 2013: Request 88297 was acted upon.
Transaction: Correspondence added by NGLENN
Queue: PAR-Packer
Subject: -M crashes pp if option contains backslashes
Broken in: 1.014
Severity: (no value)
Owner: RSCHUPP
Requestors: ***@cpan.org
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=88297 >
Post by Roderich Schupp via RT
Maybe we could check whether -M was given an absolute pathname
and at least print a warning.
This seems to do the trick:
--- lib/PAR/PackerOLD.pm 2013-09-17 00:33:16.000000000 +0400
+++ lib/PAR/Packer.pm 2013-09-17 00:33:16.000000000 +0400
@@ -675,6 +675,9 @@
my (@modules, @data, @exclude);
foreach my $name (@{ $opt->{M} || [] }) {
+ if(File::Spec->file_name_is_absolute($name)){
+ $self->_warn('Absolute path used in -M option');
+ }
$self->_name2moddata($name, \@modules, \@data);
}

I don't know if $self->_warn is a good thing to do here, since it prints the line number in Packer.pm, potentially making the user think that there's something wrong with the module. Don't know if the message is the best either.
Roderich Schupp via RT
2013-10-09 11:43:01 UTC
Permalink
Wed Oct 09 07:43:00 2013: Request 88297 was acted upon.
Transaction: Correspondence added by RSCHUPP
Queue: PAR-Packer
Subject: -M crashes pp if option contains backslashes
Broken in: 1.014
Severity: (no value)
Owner: RSCHUPP
Requestors: ***@cpan.org
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=88297 >


Fixed in PAR::Packer 1.015

Loading...