Zip files should always use forward-slashes in paths (see e.g. this bug report for a citation).
In threedifferentplaces in epub.rs, a path is created using Path::new("OEBPS").join(...), which uses the default path item separator for the platform. On Windows, this is a backslash.
ZipCommand handles this correctly, but ZipLibrary passes the path on verbatim. The resulting EPUB fails validation at http://validator.idpf.org/ because of files mentioned in the manifest that it can't find (e.g. OEBPS/foo.html) and files that it can see but aren't in the manifest (e.g. OEBPS\foo.html).
let file = format!("{}", path.as_ref().display()).replace('\\', "/");
which feels like a hack, but works. I suspect a proper fix would involve also fixing up paths added to the manifest, in case a user adds an EpubContent with a \ in it.
Sorry to have taken so much time, but it should be fixed (I used your suggestion, but only on Windows; I'll try to think of a better fix later). Thanks!
Zip files should always use forward-slashes in paths (see e.g. this bug report for a citation).
In three different places in
epub.rs
, a path is created usingPath::new("OEBPS").join(...)
, which uses the default path item separator for the platform. On Windows, this is a backslash.ZipCommand
handles this correctly, butZipLibrary
passes the path on verbatim. The resulting EPUB fails validation at http://validator.idpf.org/ because of files mentioned in the manifest that it can't find (e.g.OEBPS/foo.html
) and files that it can see but aren't in the manifest (e.g.OEBPS\foo.html
).A simple solution that I've tested locally is changing https://github.com/lise-henry/epub-builder/blob/master/src/zip_library.rs#L59 to
which feels like a hack, but works. I suspect a proper fix would involve also fixing up paths added to the manifest, in case a user adds an
EpubContent
with a\
in it.