From f6a568bcc1dbada3e5ebfe0bf61d1dad39ade915 Mon Sep 17 00:00:00 2001 From: Apprentice Harper Date: Sun, 27 Dec 2020 12:16:11 +0000 Subject: [PATCH] Update ineptepub.py Handle uncompressed elements (if any) in the zip file. --- DeDRM_plugin/ineptepub.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/DeDRM_plugin/ineptepub.py b/DeDRM_plugin/ineptepub.py index 8d88733..fb67cb4 100644 --- a/DeDRM_plugin/ineptepub.py +++ b/DeDRM_plugin/ineptepub.py @@ -353,12 +353,16 @@ class Decryptor(object): def decompress(self, bytes): dc = zlib.decompressobj(-15) - bytes = dc.decompress(bytes) - ex = dc.decompress(b'Z') + dc.flush() - if ex: - bytes = bytes + ex - return bytes - + try: + decompressed_bytes = dc.decompress(bytes) + ex = dc.decompress(b'Z') + dc.flush() + if ex: + decompressed_bytes = decompressed_bytes + ex + except: + # possibly not compressed by zip - just return bytes + return bytes + return decompressed_bytes + def decrypt(self, path, data): if path.encode('utf-8') in self._encrypted: data = self._aes.decrypt(data)[16:]