Skip to content
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

RubyZip successfully opens a completely blank "zip file" #539

Open
weshatheleopard opened this issue Nov 3, 2022 · 3 comments
Open

RubyZip successfully opens a completely blank "zip file" #539

weshatheleopard opened this issue Nov 3, 2022 · 3 comments

Comments

@weshatheleopard
Copy link
Contributor

weshatheleopard commented Nov 3, 2022

> Zip::File.open_buffer('')
=> #<Zip::File:0x00007f5e6803de50 @entry_set=#<Zip::EntrySet:0x00007f5e6803dcc0 @entry_set={}>, @comment="", @name=#<StringIO:0x00007f5e6803de78>, .......

The expectation would be that such attempt fails with an "invalid ZIP format" error, as the "file" doesn't even have the ZIP signature ('PK') at the start.

@hainesr
Copy link
Member

hainesr commented Nov 5, 2022

Which version of Rubyzip are you using?

Older versions seem to assume that when a buffer is passed then it is creating a new zip - so this would succeed by default.

@weshatheleopard
Copy link
Contributor Author

Version 2.3.2

And no, I've been passing a buffer with a downloaded ZIP file to open, for years by now.

It's just that recently the website I was downloading the zip file from, started returning zero-length file. And instead of erring out that there's no archive to read from to begin with, ZIP gem claimed that there is an archive but there are no files in it, which sent me down the wrong path.

@hainesr
Copy link
Member

hainesr commented Nov 6, 2022

Oh yes, it will still work, but it does set the create flag on buffers, so an empty buffer wouldn't be raised as an error. This is changed in the (as yet unreleased) version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants