readium / readium-js-viewer

👁 ReadiumJS viewer: default web app for Readium.js library
BSD 3-Clause "New" or "Revised" License
551 stars 186 forks source link

font decryption failing #753

Closed mohan9000 closed 3 years ago

mohan9000 commented 3 years ago

encrypted fonts are not loading

This issue is a Bug|Feature Request

Expected Behaviour

What you expected Readium to do render the fonts which are encrypted

Observed behaviour

Instead, Readium does not rendering the fonts which are rendering

danielweck commented 3 years ago

Hello, what Git revision of the software are you using? Do you have a test EPUB to reproduce the issue?

mohan9000 commented 3 years ago

we noticed that if we remove the prefix enc: from all elements in the encryption.xml file and encoding = 'UTF-8' container.xml , it is working .but if these files having enc: in encryption.xml and encoding='UTF-8' in container.xml it is not working ,

note: we are using readium-js-viewer version 0.31.1

danielweck commented 3 years ago

Related issue: https://github.com/readium/readium-js/issues/183#issuecomment-780327426

mohan9000 commented 3 years ago

http://ns.adobe.com/pdf/enc#RC http://www.idpf.org/2008/embedding is there any difference between these two algorithms @danielweck

danielweck commented 3 years ago

Font deobfuscation code:

IDPF http://www.idpf.org/2008/embedding:

https://github.com/readium/readium-js/blob/9facb57dc4dc6df75eb24c0be982d0d1fd675988/js/epub-fetch/encryption_handler.js#L51-L58

Adobe http://ns.adobe.com/pdf/enc#RC:

https://github.com/readium/readium-js/blob/9facb57dc4dc6df75eb24c0be982d0d1fd675988/js/epub-fetch/encryption_handler.js#L76-L83

mohan9000 commented 3 years ago

@danielweck Hi Daniel I am sharing the content which have issues with encrypted fonts .Please verify and provide some solutions. 9781647470258.zip

danielweck commented 3 years ago

Thank you for the test sample. I am able to reproduce the font de-obfuscation failure, because of the enc XML namespace prefix in encryption.xml.

In the interim until a proper fix is implemented, you may add enc: before the EncryptedData, EncryptedMethod and CipherReference jQuery selectors:

var encryptedData = $('EncryptedData', encryptionDom);

var encryptionAlgorithm = $('EncryptionMethod', encryptedData).first().attr('Algorithm');

var cipherReference = $('CipherReference', encryptedData);

https://github.com/readium/readium-js/blob/9facb57dc4dc6df75eb24c0be982d0d1fd675988/js/epub-fetch/encryption_handler.js#L141-L146

danielweck commented 3 years ago

Fixed via https://github.com/readium/readium-js/commit/b2c65bf3dd3b47ec716d328479a3c8af51fde0d2

danielweck commented 3 years ago

You can test your EPUB by drag-n-drop on the web reader window: https://readium.web.app Alternative link: https://readium.surge.sh You can download the latest web reader build (Readium_cloud-reader.zip) from: https://github.com/readium/readium-js-viewer/releases/tag/0.32.0-alpha