Skip to content

Commit

Permalink
Fix font decryption with multiple IDs (apprenticeharper#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
noDRM committed Jun 23, 2023
1 parent 740b465 commit a553a71
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,4 @@ List of changes since the fork of Apprentice Harper's repository:
- Bugfix: EPUBs with remaining content in the encryption.xml after decryption weren't written correctly.
- Support for Adobe's 'aes128-cbc-uncompressed' encryption method (fixes #242).
- Two bugfixes for Amazon DeDRM from Satuoni ( https://github.com/noDRM/DeDRM_tools/issues/315#issuecomment-1508305428 ) and andrewc12 ( https://github.com/andrewc12/DeDRM_tools/commit/d9233d61f00d4484235863969919059f4d0b2057 ) that might make the plugin work with newer versions.
- Fix font decryption not working with some books (fixes #347), thanks for the patch @bydioeds.
12 changes: 7 additions & 5 deletions DeDRM_plugin/epubfontdecrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
# -*- coding: utf-8 -*-

# epubfontdecrypt.py
# Copyright © 2021 by noDRM
# Copyright © 2021-2023 by noDRM

# Released under the terms of the GNU General Public Licence, version 3
# <http://www.gnu.org/licenses/>


# Revision history:
# 1 - Initial release
# 2 - Bugfix for multiple book IDs, reported at #347

"""
Decrypts / deobfuscates font files in EPUB files
Expand All @@ -18,7 +19,7 @@
from __future__ import print_function

__license__ = 'GPL v3'
__version__ = "1"
__version__ = "2"

import os
import traceback
Expand Down Expand Up @@ -193,9 +194,10 @@ def decryptFontsBook(inpath, outpath):
pass

try:
identify_element = container.find(packageNS("metadata")).find(metadataDCNS("identifier"))
if (secret_key_name is None or secret_key_name == identify_element.get("id")):
font_master_key = identify_element.text
identify_elements = container.find(packageNS("metadata")).findall(metadataDCNS("identifier"))
for element in identify_elements:
if (secret_key_name is None or secret_key_name == element.get("id")):
font_master_key = element.text
except:
pass

Expand Down

0 comments on commit a553a71

Please sign in to comment.