Handle stored files with general purpose bit 3 set
Signed-off-by: Sam Coward <scoward@pivotal.io>
This commit is contained in:
parent
05af1231f4
commit
c787d94852
|
@ -500,7 +500,7 @@ module Zip
|
|||
end
|
||||
else
|
||||
zis = ::Zip::InputStream.new(@zipfile, local_header_offset)
|
||||
zis.instance_variable_set(:@internal, true)
|
||||
zis.instance_variable_set(:@complete_entry, self)
|
||||
zis.get_next_entry
|
||||
if block_given?
|
||||
begin
|
||||
|
|
|
@ -129,7 +129,7 @@ module Zip
|
|||
end
|
||||
if @current_entry && @current_entry.gp_flags & 8 == 8 && @current_entry.crc == 0 \
|
||||
&& @current_entry.compressed_size == 0 \
|
||||
&& @current_entry.size == 0 && !@internal
|
||||
&& @current_entry.size == 0 && !@complete_entry
|
||||
raise GPFBit3Error,
|
||||
'General purpose flag Bit 3 is set so not possible to get proper info from local header.' \
|
||||
'Please use ::Zip::File instead of ::Zip::InputStream'
|
||||
|
@ -143,7 +143,11 @@ module Zip
|
|||
if @current_entry.nil?
|
||||
::Zip::NullDecompressor
|
||||
elsif @current_entry.compression_method == ::Zip::Entry::STORED
|
||||
::Zip::PassThruDecompressor.new(@archive_io, @current_entry.size)
|
||||
if @current_entry.gp_flags & 8 == 8 && @current_entry.crc == 0 && @current_entry.size == 0 && @complete_entry
|
||||
::Zip::PassThruDecompressor.new(@archive_io, @complete_entry.size)
|
||||
else
|
||||
::Zip::PassThruDecompressor.new(@archive_io, @current_entry.size)
|
||||
end
|
||||
elsif @current_entry.compression_method == ::Zip::Entry::DEFLATED
|
||||
header = @archive_io.read(@decrypter.header_bytesize)
|
||||
@decrypter.reset!(header)
|
||||
|
|
Binary file not shown.
|
@ -55,6 +55,12 @@ class ZipFileTest < MiniTest::Test
|
|||
assert_equal(2, zfRead.entries.length)
|
||||
end
|
||||
|
||||
def test_get_input_stream_stored_with_gpflag_bit3
|
||||
::Zip::File.open('test/data/gpbit3stored.zip') do |zf|
|
||||
assert_equal("foo\n", zf.read("foo.txt"))
|
||||
end
|
||||
end
|
||||
|
||||
def test_get_output_stream
|
||||
entryCount = nil
|
||||
::Zip::File.open(TEST_ZIP.zip_name) do |zf|
|
||||
|
|
Loading…
Reference in New Issue