From e8e1ad71eb01c63720bfc2df0d7be732fab59199 Mon Sep 17 00:00:00 2001 From: GammaC0de Date: Tue, 20 Oct 2015 01:51:38 +0300 Subject: [UnZip] fix verify() --- module/plugins/internal/UnZip.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'module/plugins/internal/UnZip.py') diff --git a/module/plugins/internal/UnZip.py b/module/plugins/internal/UnZip.py index 8788f9ca5..c14742efa 100644 --- a/module/plugins/internal/UnZip.py +++ b/module/plugins/internal/UnZip.py @@ -41,12 +41,21 @@ class UnZip(Extractor): def verify(self, password=None): with zipfile.ZipFile(self.target, 'r', allowZip64=True) as z: - badfile = z.testzip() + z.setpassword(password) + + try: + badfile = z.testzip() + + except RuntimeError, e: + if "encrypted" in e.message: + raise PasswordError + else: + raise CRCError("Archive damaged") - if badfile: - raise CRCError(badfile) else: - raise PasswordError + if badfile: + raise CRCError(badfile) + def extract(self, password=None): -- cgit v1.2.3