8000 Support decompressor plugins by jspanjers · Pull Request #427 · rubyzip/rubyzip · GitHub
[go: up one dir, main page]

Skip to content

Support decompressor plugins #427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Feb 1, 2020
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix returned outbuf for Inflater#sysread
  • Loading branch information
jspanjers committed Jan 26, 2020
commit 00b525d76e295bab19b69c6f3481d60cfda9ca0f
10 changes: 5 additions & 5 deletions lib/zip/inflater.rb
5972
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ def initialize(*args)
@has_returned_empty_string = false
end

def sysread(length = nil, buf = '')
def sysread(length = nil, outbuf = '')
while length.nil? || (@buffer.bytesize < length)
break if input_finished?
@buffer << produce_input(buf)
@buffer << produce_input
end

return value_when_finished if eof?

@buffer.slice!(0...(length || @buffer.bytesize))
outbuf.replace(@buffer.slice!(0...(length || @buffer.bytesize)))
end

def eof
Expand All @@ -27,10 +27,10 @@ def eof

private

def produce_input(buf = '')
def produce_input
retried = 0
begin
@zlib_inflater.inflate(input_stream.read(Decompressor::CHUNK_SIZE, buf))
@zlib_inflater.inflate(input_stream.read(Decompressor::CHUNK_SIZE))
rescue Zlib::BufError
raise if retried >= 5 # how many times should we retry?
retried += 1
Expand Down
0