Skip to content

Commit

Permalink
Fix epub specification violation (#113)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
matteo-l authored May 20, 2024
1 parent 1e15143 commit 23ddd73
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion kobodl/koboDrmRemover.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@ def RemoveDrm(self, inputPath: str, outputPath: str, contentKeys: Dict[str, str]
contentKeyBase64 = contentKeys.get(filename, None)
if contentKeyBase64 is not None:
contents = self.__DecryptContents(contents, contentKeyBase64)
outputZip.writestr(filename, contents)
if filename == "mimetype":
outputZip.writestr(filename, contents, compress_type=zipfile.ZIP_STORED)
else:
outputZip.writestr(filename, contents)

0 comments on commit 23ddd73

Please sign in to comment.