summaryrefslogtreecommitdiffstats
path: root/DeDRM_plugin/ineptepub.py
diff options
context:
space:
mode:
Diffstat (limited to 'DeDRM_plugin/ineptepub.py')
-rw-r--r--DeDRM_plugin/ineptepub.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/DeDRM_plugin/ineptepub.py b/DeDRM_plugin/ineptepub.py
index 6b4b676..094cb8c 100644
--- a/DeDRM_plugin/ineptepub.py
+++ b/DeDRM_plugin/ineptepub.py
@@ -48,6 +48,7 @@ import base64
import zlib
import zipfile
from zipfile import ZipInfo, ZipFile, ZIP_STORED, ZIP_DEFLATED
+from zeroedzipinfo import ZeroedZipInfo
from contextlib import closing
from lxml import etree
from uuid import UUID
@@ -356,12 +357,23 @@ def decryptBook(userkey, inpath, outpath):
zi.internal_attr = oldzi.internal_attr
# external attributes are dependent on the create system, so copy both.
zi.external_attr = oldzi.external_attr
+
+ zi.volume = oldzi.volume
zi.create_system = oldzi.create_system
+ zi.create_version = oldzi.create_version
+
if any(ord(c) >= 128 for c in path) or any(ord(c) >= 128 for c in zi.comment):
# If the file name or the comment contains any non-ASCII char, set the UTF8-flag
zi.flag_bits |= 0x800
except:
pass
+
+ # Python 3 has a bug where the external_attr is reset to `0o600 << 16`
+ # if it's NULL, so we need a workaround:
+ if zi.external_attr == 0:
+ zi = ZeroedZipInfo(zi)
+
+
if path == "META-INF/encryption.xml":
outf.writestr(zi, data)
else: