Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

Error on Kobo while zipping .epub files #151

Closed
JeremyAube opened this issue Jun 18, 2020 · 7 comments
Closed

Error on Kobo while zipping .epub files #151

JeremyAube opened this issue Jun 18, 2020 · 7 comments
Labels

Comments

@JeremyAube
Copy link
Contributor

Using this library to zip .epub files results in an error when trying to open on Kobo Clara HD e-reader.

The error only occurs when the files are zipped with this library. When I zip files with system's zip command, the resulting .epub is valid.

Here is the comparison of the zip-rs file vs the system's zip command file using zipinfo on Ubuntu:
zip-rs

$ zipinfo zip-rs.epub 
Archive:  zip-rs.epub
Zip file size: 10702 bytes, number of entries: 9
-rw-r--r--  4.6 unx       20 b- stor 20-Jun-18 09:07 mimetype
-rw-r--r--  4.6 unx      253 b- defN 20-Jun-18 09:07 META-INF/container.xml
-rw-r--r--  4.6 unx      161 b- defN 20-Jun-18 09:07 META-INF/com.apple.ibooks.display-options.xml
-rw-r--r--  4.6 unx      563 b- defN 20-Jun-18 09:07 OEBPS/chapter_1.html
-rw-r--r--  4.6 unx     5687 b- defN 20-Jun-18 09:07 OEBPS/stylesheet.css
-rw-r--r--  4.6 unx     5758 b- defN 20-Jun-18 09:07 OEBPS/rust-logo.png
-rw-r--r--  4.6 unx     1109 b- defN 20-Jun-18 09:07 OEBPS/content.opf
-rw-r--r--  4.6 unx      497 b- defN 20-Jun-18 09:07 OEBPS/toc.ncx
-rw-r--r--  4.6 unx      645 b- defN 20-Jun-18 09:07 OEBPS/nav.xhtml

zip command

$ zipinfo zip.epub
Archive:  zip.epub
Zip file size: 10871 bytes, number of entries: 11
-rw-r--r--  3.0 unx       20 t- stor 20-Jun-18 08:42 mimetype
drwxrwxr-x  3.0 unx        0 b- stor 20-Jun-18 08:42 META-INF/
-rw-r--r--  3.0 unx      253 t- defN 20-Jun-18 08:42 META-INF/container.xml
-rw-r--r--  3.0 unx      161 t- defN 20-Jun-18 08:42 META-INF/com.apple.ibooks.display-options.xml
drwxrwxr-x  3.0 unx        0 b- stor 20-Jun-18 08:42 OEBPS/
-rw-r--r--  3.0 unx     5687 t- defN 20-Jun-18 08:42 OEBPS/stylesheet.css
-rw-r--r--  3.0 unx      645 t- defN 20-Jun-18 08:42 OEBPS/nav.xhtml
-rw-r--r--  3.0 unx     5758 b- stor 20-Jun-18 08:42 OEBPS/rust-logo.png
-rw-r--r--  3.0 unx     1109 t- defN 20-Jun-18 08:42 OEBPS/content.opf
-rw-r--r--  3.0 unx      563 t- defN 20-Jun-18 08:42 OEBPS/chapter_1.html
-rw-r--r--  3.0 unx      497 t- defN 20-Jun-18 08:42 OEBPS/toc.ncx
11 files, 14693 bytes uncompressed, 9625 bytes compressed:  34.5%

The Kobo says the book is "protected by Adobe DRM" but I have been told that this error is kind of a default error and that it doesn't necessarily mean that the book is protected. In my case I did not protected the ebook.

I am not sure as to what causes the issue but I believe it can be one of two things

  1. This library adds a comment to the zip file (default zip-rs)
  2. The xhtml files are detected as binary files instead of text files. I am not sure why that is.

This library is used by https://github.com/lise-henry/epub-builder/

The issue has been discussed here: Michael-F-Bryan/mdbook-epub#28

@rylev rylev added the bug label Jun 18, 2020
@justinclift
Copy link

The xhtml files are detected as binary files instead of text files. I am not sure why that is.

One potential reason was mentioned earlier in the mdbook-epub thread: Michael-F-Bryan/mdbook-epub#28 (comment)

On the last point I'll quote @lise-henry hint on the issue I opened on its library repo

> From what I see, the HTML files only contain the body part and is missing the
> beginning and end for a full XHTML that is required to be understood as valid,
> e.g.

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
<body>
...
</body>
</html>

Potentially easy to fix?

@JeremyAube
Copy link
Contributor Author

Well actually all the of files are detected as binary files as denoted by the b- in the zipinfo output.

Here are the reasons that lead me to believe that lib-rs is causing the issue:

  1. epub-builder has a comment saying that using zip-rs causes problems on e-readers, and she builds the book with the correct XHTML format;
  2. If you zip all the same XHTML files manually with the zip command, the resulting .epub is valid;

I do believe this is something we have to address. But that should be an issue in the https://github.com/Michael-F-Bryan/mdbook-epub repository.

@joshuarli
Copy link

joshuarli commented Jun 19, 2020

Oh hey, this is a really timely issue. I just encountered the same exact thing with zip-rs here while trying to port external usage of zip to zip-rs: joshuarli/epub-optimizer@a23c994

zipinfo is also telling me that archives created with zip-rs (I largely copied the example code) have b- for every entry. I suspect that's the issue. For me, it's manifesting as Apple Books telling me the EPUB is "corrupt".

@mvdnes
Copy link
Collaborator

mvdnes commented Jun 21, 2020

Testing on my Kobo Aura 2, I found that when setting the comment of the zip archive to the empty string, the epub opens fine. You might want to file an issue in the epub-builder library instead.

@mvdnes mvdnes closed this as completed Jun 21, 2020
@mvdnes
Copy link
Collaborator

mvdnes commented Jun 21, 2020

On the binary vs text subject: the way zipinfo determines if a file is binary or text is by reading the 'internal attributes' field. This library never sets any flags in this field at the moment, so zipinfo will always determine it to be binary, regardless of the contents.

@JeremyAube
Copy link
Contributor Author

Great find! Though I believe that if the zip comment causes issues on some devices it shouldn't be set by default by this library.

@joshuarli
Copy link

Oh hey, this is a really timely issue. I just encountered the same exact thing with zip-rs here while trying to port external usage of zip to zip-rs: joshuarli/epub-optimizer@a23c994

zipinfo is also telling me that archives created with zip-rs (I largely copied the example code) have b- for every entry. I suspect that's the issue. For me, it's manifesting as Apple Books telling me the EPUB is "corrupt".

Sorry - long story short, this was entirely a bug on my end. The "zip-rs" comment had nothing to do with corruption here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants