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

Fail on Deflate64 compressed files #10

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions sflock/unpack/zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ def _decrypt(self, archive, entry, password):
contents=archive.read(entry),
password=password
)
except NotImplementedError as nae:
# Deflate64
# Instead of throwing an UnpackException return failed.
# TODO: 7z supports this format, so pick could be updated to detect this
# compression type and use the 7z unpacker instead.
#
if "compression type 9" in nae.args[0]:
return File(
relapath=entry.filename,
mode="failed",
description="%s" % nae
)
except RuntimeError as e:
if "password required" not in e.args[0] and \
"Bad password" not in e.args[0]:
Expand Down
Binary file added tests/files/zip_deflate64.zip
Binary file not shown.
10 changes: 10 additions & 0 deletions tests/test_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,13 @@ def test_garbage2(self):
assert len(files) == 1
assert not files[0].children
assert files[0].mode == "failed"

def test_deflate64(self):
t = ZipFile(f("zip_deflate64.zip"))
assert t.handles() is True
assert not t.f.selected
files = t.unpack()
assert len(files) == 1
assert not files[0].children
assert files[0].mode == "failed"