File tree 4 files changed +13
-3
lines changed 4 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -500,7 +500,7 @@ def get_input_stream(&block)
500
500
end
501
501
else
502
502
zis = ::Zip ::InputStream . new ( @zipfile , local_header_offset )
503
- zis . instance_variable_set ( :@internal , true )
503
+ zis . instance_variable_set ( :@complete_entry , self )
504
504
zis . get_next_entry
505
505
if block_given?
506
506
begin
Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ def open_entry
129
129
end
130
130
if @current_entry && @current_entry . gp_flags & 8 == 8 && @current_entry . crc == 0 \
131
131
&& @current_entry . compressed_size == 0 \
132
- && @current_entry . size == 0 && !@internal
132
+ && @current_entry . size == 0 && !@complete_entry
133
133
raise GPFBit3Error ,
134
134
'General purpose flag Bit 3 is set so not possible to get proper info from local header.' \
135
135
'Please use ::Zip::File instead of ::Zip::InputStream'
@@ -143,7 +143,11 @@ def get_decompressor
143
143
if @current_entry . nil?
144
144
::Zip ::NullDecompressor
145
145
elsif @current_entry . compression_method == ::Zip ::Entry ::STORED
146
- ::Zip ::PassThruDecompressor . new ( @archive_io , @current_entry . size )
146
+ if @current_entry . gp_flags & 8 == 8 && @current_entry . crc == 0 && @current_entry . size == 0 && @complete_entry
147
+ ::Zip ::PassThruDecompressor . new ( @archive_io , @complete_entry . size )
148
+ else
149
+ ::Zip ::PassThruDecompressor . new ( @archive_io , @current_entry . size )
150
+ end
147
151
elsif @current_entry . compression_method == ::Zip ::Entry ::DEFLATED
148
152
header = @archive_io . read ( @decrypter . header_bytesize )
149
153
@decrypter . reset! ( header )
Original file line number Diff line number Diff line change @@ -55,6 +55,12 @@ def test_create_from_scratch_with_old_create_parameter
55
55
assert_equal ( 2 , zfRead . entries . length )
56
56
end
57
57
58
+ def test_get_input_stream_stored_with_gpflag_bit3
59
+ ::Zip ::File . open ( 'test/data/gpbit3stored.zip' ) do |zf |
60
+ assert_equal ( "foo\n " , zf . read ( "foo.txt" ) )
61
+ end
62
+ end
63
+
58
64
def test_get_output_stream
59
65
entryCount = nil
60
66
::Zip ::File . open ( TEST_ZIP . zip_name ) do |zf |
You can’t perform that action at this time.
0 commit comments