diff options
Diffstat (limited to 'gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Unzip.pm')
-rw-r--r-- | gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Unzip.pm | 64 |
1 files changed, 51 insertions, 13 deletions
diff --git a/gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Unzip.pm b/gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Unzip.pm index 4e8a0d67c7a..856487f8fcd 100644 --- a/gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Unzip.pm +++ b/gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Unzip.pm @@ -9,17 +9,20 @@ use warnings; use bytes; use IO::File; -use IO::Uncompress::RawInflate 2.084 ; -use IO::Compress::Base::Common 2.084 qw(:Status ); -use IO::Uncompress::Adapter::Inflate 2.084 ; -use IO::Uncompress::Adapter::Identity 2.084 ; -use IO::Compress::Zlib::Extra 2.084 ; -use IO::Compress::Zip::Constants 2.084 ; +use IO::Uncompress::RawInflate 2.093 ; +use IO::Compress::Base::Common 2.093 qw(:Status ); +use IO::Uncompress::Adapter::Inflate 2.093 ; +use IO::Uncompress::Adapter::Identity 2.093 ; +use IO::Compress::Zlib::Extra 2.093 ; +use IO::Compress::Zip::Constants 2.093 ; -use Compress::Raw::Zlib 2.084 () ; +use Compress::Raw::Zlib 2.093 () ; BEGIN { + # Don't trigger any __DIE__ Hooks. + local $SIG{__DIE__}; + eval{ require IO::Uncompress::Adapter::Bunzip2 ; import IO::Uncompress::Adapter::Bunzip2 } ; eval{ require IO::Uncompress::Adapter::UnLzma ; @@ -31,7 +34,7 @@ require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $UnzipError, %headerLookup); -$VERSION = '2.084'; +$VERSION = '2.093'; $UnzipError = ''; @ISA = qw(IO::Uncompress::RawInflate Exporter); @@ -70,6 +73,7 @@ sub getExtraParams 'name' => [IO::Compress::Base::Common::Parse_any, undef], 'stream' => [IO::Compress::Base::Common::Parse_boolean, 0], + 'efs' => [IO::Compress::Base::Common::Parse_boolean, 0], # TODO - This means reading the central directory to get # 1. the local header offsets @@ -86,6 +90,7 @@ sub ckParams $got->setValue('crc32' => 1); *$self->{UnzipData}{Name} = $got->getValue('name'); + *$self->{UnzipData}{efs} = $got->getValue('efs'); return 1; } @@ -551,6 +556,7 @@ sub _readZipHeader($) my $extraField; my @EXTRA = (); my $streamingMode = ($gpFlag & ZIP_GP_FLAG_STREAMING_MASK) ? 1 : 0 ; + my $efs_flag = ($gpFlag & ZIP_GP_FLAG_LANGUAGE_ENCODING) ? 1 : 0; return $self->HeaderError("Encrypted content not supported") if $gpFlag & (ZIP_GP_FLAG_ENCRYPTED_MASK|ZIP_GP_FLAG_STRONG_ENCRYPTED_MASK); @@ -565,6 +571,14 @@ sub _readZipHeader($) { $self->smartReadExact(\$filename, $filename_length) or return $self->TruncatedHeader("Filename"); + + if (*$self->{UnzipData}{efs} && $efs_flag && $] >= 5.008004) + { + require Encode; + eval { $filename = Encode::decode_utf8($filename, 1) } + or Carp::croak "Zip Filename not UTF-8" ; + } + $keep .= $filename ; } @@ -705,6 +719,7 @@ sub _readZipHeader($) 'UncompressedLength' => $uncompressedLength , 'CRC32' => $crc32 , 'Name' => $filename, + 'efs' => $efs_flag, # language encoding flag 'Time' => _dosToUnixTime($lastModTime), 'Stream' => $streamingMode, @@ -1107,7 +1122,8 @@ The functional interface needs Perl5.005 or better. =head2 unzip $input_filename_or_reference => $output_filename_or_reference [, OPTS] C<unzip> expects at least two parameters, -C<$input_filename_or_reference> and C<$output_filename_or_reference>. +C<$input_filename_or_reference> and C<$output_filename_or_reference> +and zero or more optional parameters (see L</Optional Parameters>) =head3 The C<$input_filename_or_reference> parameter @@ -1120,7 +1136,7 @@ It can take one of the following forms: =item A filename -If the <$input_filename_or_reference> parameter is a simple scalar, it is +If the C<$input_filename_or_reference> parameter is a simple scalar, it is assumed to be a filename. This file will be opened for reading and the input data will be read from it. @@ -1217,9 +1233,9 @@ files/buffers. =head2 Optional Parameters -Unless specified below, the optional parameters for C<unzip>, -C<OPTS>, are the same as those used with the OO interface defined in the -L</"Constructor Options"> section below. +The optional parameters for the one-shot function C<unzip> +are (for the most part) identical to those used with the OO interface defined in the +L</"Constructor Options"> section. The exceptions are listed below =over 5 @@ -1431,6 +1447,18 @@ OPTS is a combination of the following options: Open "membername" from the zip file for reading. +=item C<< Efs => 0| 1 >> + +When this option is set to true AND the zip archive being read has +the "Language Encoding Flag" (EFS) set, the member name is assumed to be encoded in UTF-8. + +If the member name in the zip archive is not valid UTF-8 when this optionn is true, +the script will die with an error message. + +Note that this option only works with Perl 5.8.4 or better. + +This option defaults to B<false>. + =item C<< AutoClose => 0|1 >> This option is only valid when the C<$input> parameter is a filehandle. If @@ -1731,6 +1759,10 @@ Skips to the next compressed data stream in the input file/buffer. If a new compressed data stream is found, the eof marker will be cleared and C<$.> will be reset to 0. +If trailing data is present immediately after the zip archive and the +C<Transparent> option is enabled, this method will consider that trailing +data to be another member of the zip archive. + Returns 1 if a new stream was found, 0 if none was found, and -1 if an error was encountered. @@ -1828,6 +1860,12 @@ to read a zip file and unzip its contents to disk. The script is available from L<https://gist.github.com/eqhmcow/5389877> +=head1 SUPPORT + +General feedback/questions/bug reports should be sent to +L<https://github.com/pmqs/IO-Compress/issues> (preferred) or +L<https://rt.cpan.org/Public/Dist/Display.html?Name=IO-Compress>. + =head1 SEE ALSO L<Compress::Zlib>, L<IO::Compress::Gzip>, L<IO::Uncompress::Gunzip>, L<IO::Compress::Deflate>, L<IO::Uncompress::Inflate>, L<IO::Compress::RawDeflate>, L<IO::Uncompress::RawInflate>, L<IO::Compress::Bzip2>, L<IO::Uncompress::Bunzip2>, L<IO::Compress::Lzma>, L<IO::Uncompress::UnLzma>, L<IO::Compress::Xz>, L<IO::Uncompress::UnXz>, L<IO::Compress::Lzip>, L<IO::Uncompress::UnLzip>, L<IO::Compress::Lzop>, L<IO::Uncompress::UnLzop>, L<IO::Compress::Lzf>, L<IO::Uncompress::UnLzf>, L<IO::Compress::Zstd>, L<IO::Uncompress::UnZstd>, L<IO::Uncompress::AnyInflate>, L<IO::Uncompress::AnyUncompress> |