Skip to content

Commit 23ddd73

Browse files
authored
Fix epub specification violation (#113)
According to the epub specifications (https://www.w3.org/TR/epub/#sec-zip-container-mime) epub creators must not compress the mimetype file in the epub. The updated RemoveDrm function creates a new zip file with using the `ZIP_DEFLATED` compression method for all the files, except mimetype
1 parent 1e15143 commit 23ddd73

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

kobodl/koboDrmRemover.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,7 @@ def RemoveDrm(self, inputPath: str, outputPath: str, contentKeys: Dict[str, str]
3636
contentKeyBase64 = contentKeys.get(filename, None)
3737
if contentKeyBase64 is not None:
3838
contents = self.__DecryptContents(contents, contentKeyBase64)
39-
outputZip.writestr(filename, contents)
39+
if filename == "mimetype":
40+
outputZip.writestr(filename, contents, compress_type=zipfile.ZIP_STORED)
41+
else:
42+
outputZip.writestr(filename, contents)

0 commit comments

Comments
 (0)