Bug 697619 - Ignore EPUB DRM when not necessary
Summary: Ignore EPUB DRM when not necessary
Status: RESOLVED DUPLICATE of bug 705640
Alias: None
Product: MuPDF
Classification: Unclassified
Component: epub (show other bugs)
Version: 1.9
Hardware: PC Linux
: P4 minor
Assignee: MuPDF bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-28 19:19 UTC by bohwaz
Modified: 2023-05-09 10:56 UTC (History)
3 users (show)

See Also:
Customer:
Word Size: ---


Attachments
A sample META-INF/encryption.xml with font XOR obfuscation. (1.66 KB, application/xml)
2021-10-31 09:47 UTC, Ralph Corderoy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bohwaz 2017-02-28 19:19:38 UTC
I've got an EPUB3 file and mupdf fails with:

error: EPUB is locked by DRM
mupdf: error: cannot open document

Looking into the EPUB zip file I can see that the only files encrypted are the fonts, not really necessary for displaying stuff.

Could it be possible to not fail when a META-INF/encryption.xml if it only mentions trivial stuff like pictures and fonts? Or add a prompt or a command line switch to ignore that file?

Thank you.
Comment 1 bohwaz 2017-03-01 13:42:30 UTC
Ah seems that the fonts are just obfuscated, not even encrypted: http://www.idpf.org/epub/20/spec/FontManglingSpec.html
Comment 2 Francesco Turco 2017-04-02 07:54:01 UTC
I can reproduce this bug with one of my ePub files, too. It's a matter of encrypted font files, which should not be strictly required in my opinion.
Comment 3 Francesco Turco 2018-03-15 09:26:32 UTC
Created attachment 14898 [details]
essentialism.epub
Comment 4 farid 2019-10-24 07:22:02 UTC
I have the same issue with serveral epub files. If I remove META-INF/encryption.xml file in the epub file, mupdf opens the file fine. Otherwise, it gives the error. Please fix.
thanks
Comment 5 farid 2020-11-03 14:40:03 UTC
Hi,

I use this shell function to workaround it:


# to make mupdf open some DeDRMed epubs
function dedrm(){
  declare css=page_styles.css
  zip -d "$1" META-INF/encryption.xml
  zip -d "$1" fonts/\*
  # remove references to fonts/* in the $css file.
  unzip -qc "$1" $css | sed '/@font-face/{:a /}/d; N; ba}' > $css
  zip "$1" $css && rm $css
}

I hope you find it useful.
Comment 6 Ralph Corderoy 2021-10-31 09:47:24 UTC
Created attachment 21832 [details]
A sample META-INF/encryption.xml with font XOR obfuscation.
Comment 7 Ralph Corderoy 2021-10-31 09:50:00 UTC
The status of this bug should be changed to Confirmed; I'm also suffering.

Those giving away this free EPUB are not aware there is any DRM or encryption involved and that is certainly not their intent.  The META-INF/encryption.xml has just been attached and clearly shows it is only fonts which are encrypted and all with the http://www.idpf.org/2008/embedding EncryptionMethod which is a simple XOR of the first 1040 bytes of each font with the SHA-1 digest of the <package>'s unique-identifier attribute's identifier attribute.  For example:

    <package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="bookid" ...

    <dc:identifier id="bookid">urn:uuid:FC73E98D-6B5F-4BF5-BF6B-C26820AFEB10</dc:identifier>

Given it's not really DRM or encryption, just obfuscation, and I think just tied to fonts, I'd suggest mupdf does the 'decryption' to better render the EPUB.

References:
The encryption.xml file: https://www.w3.org/publishing/epub3/epub-ocf.html#sec-container-metainf-encryption.xml
The XOR method: http://idpf.org/epub/20/spec/FontManglingSpec_2.0.1_draft.htm
Comment 8 Tor Andersson 2023-05-09 10:56:12 UTC

*** This bug has been marked as a duplicate of bug 705640 ***