# EPUB KB policy testing ## Contents of this repository A set of *EPUB* test files, specifically created for the purpose of testing an automated procedure to validate *EPUB*s against KB institutional policies. These policies require the following: * Files must be valid *EPUB* (version 2 or 3) * File may not contain DRM or encryption (edge case: font mangling, should be permitted) * All resources in the container fall within the Core Media Types * No Digital Talking Book (DTB) content documents As a result, most of the files in this repo deliberately violate one or more of the above requirements. Some of the files were newly created (with a little help from [Sigil](http://sigil-ebook.com/)), whereas others were taken or adapted from other openly-licensed data sets. ## Directories * **content** - uncompressed contents of each test file (each subdirectory represents one epub) * **build** - actual epub builds * **epubcheckout** - epubcheck output * **pubresources** - various resources (files) that were used for creating the epubs. ## Build script The script *build.sh* iterates over all subdirectories in the *content* folder and compresses the contents of each to a functional *epub* file in the *build* directory. For an explanation of how the build process works, see [here](https://gist.github.com/bitsgalore/da04413787931d20a8bf). ## Analyse script The script *analyse.sh* validates all epubs in the *build* directory with [Epubcheck](https://github.com/idpf/epubcheck) (it uses both the stable 3.0 version and the 4.0.1 one). You have to install these yourself on your system. Then update the file paths to *epubcheck3Jar* and *epubcheck4Jar* at the top of the script. ## Description of test files |File name|Epub version|Description|Epubcheck (3,4) output| |:--|:--|:--|:--| |[epub20_minimal.epub](build/epub20_minimal.epub?raw=true)|2|Basic file with one text resource and one image|[3](epubcheckout/3.0.1/epub20_minimal.xml),[4](epubcheckout/4.0.1/epub20_minimal.xml)| |[epub20_minimal_encryption.epub](build/epub20_minimal_encryption.epub?raw=true)|2|Includes encryption.xml resource in `META-INF`, indicating that main text resource is encrypted (text resource is not *actually* encrypted, BTW)|[3](epubcheckout/3.0.1/epub20_minimal_encryption.xml),[4](epubcheckout/4.0.1/epub20_minimal_encryption.xml)| |[epub30_font_obfuscation.epub](build/epub30_font_obfuscation.epub?raw=true)|3|Includes fonts that are obfuscated (which results in *hasEncryption* in epubcheck). Taken from [EPUB 3 Sample Documents](https://code.google.com/p/epub-samples/) ([*wasteland with OTF fonts, obfuscated*](https://code.google.com/p/epub-samples/downloads/detail?name=wasteland-otf-obf-20120118.epub&can=2&q=)).|[3](epubcheckout/3.0.1/epub30_font_obfuscation.xml),[4](epubcheckout/4.0.1/epub30_font_obfuscation.xml)| |[epub20_foreign_resource_no_fallback.epub](build/epub20_foreign_resource_no_fallback.epub?raw=true)|2|Includes JP2 image, which is a format that is not on the list of Core Media Types; no fallback defined|[3](epubcheckout/3.0.1/epub20_foreign_resource_no_fallback.xml),[4](epubcheckout/4.0.1/epub20_foreign_resource_no_fallback.xml)| |[epub20_foreign_resource_with_fallback.epub](build/epub20_foreign_resource_with_fallback.epub?raw=true)|2|Includes JP2 image, which is a format that is not on the list of Core Media Types; fallback defined in manifest, identifier in content document|[3](epubcheckout/3.0.1/epub20_foreign_resource_with_fallback.xml),[4](epubcheckout/4.0.1/epub20_foreign_resource_with_fallback.xml)| |[epub20_foreign_resource_with_fallback_noID.epub](build/epub20_foreign_resource_with_fallback_noID.epub?raw=true)|2|Includes JP2 image, which is a format that is not on the list of Core Media Types; fallback defined in manifest, no identifier in content document|[3](epubcheckout/3.0.1/epub20_foreign_resource_with_fallback_noID.xml),[4](epubcheckout/4.0.1/epub20_foreign_resource_with_fallback_noID.xml)| |[epub20_dtbook.epub](build/epub20_dtbook.epub?raw=true)|2|Includes Digital Talking Book content. Adapted from [threepress](https://code.google.com/p/threepress/source/browse/branches/bookworm-caching/library/test-data/data/hauy.epub?r=583), published under [BSD 3](http://opensource.org/licenses/BSD-3-Clause) license.|[3](epubcheckout/3.0.1/epub20_dtbook.xml),[4](epubcheckout/4.0.1/epub20_dtbook.xml)| |[epub20_xpgt.epub](build/epub20_xpgt.epub?raw=true)|2|Includes style definitions as [Adobe Page Template](http://wiki.mobileread.com/wiki/XPGT).|[3](epubcheckout/3.0.1/epub20_xpgt.xml),[4](epubcheckout/4.0.1/epub20_xpgt.xml)| |[epub20_missingfontresource.epub](build/epub20_missingfontresource.epub?raw=true)|2|CSS stylesheet contains reference to font resource that is not part of the package.|[3](epubcheckout/3.0.1/epub20_missingfontresource.xml),[4](epubcheckout/3.0.1/epub20_missingfontresource.xml)| |[epub20__invalid_entity](build/epub20_invalid_entity.epub?raw=true)|2|HTML contains illegal control character|[3](epubcheckout/3.0.1/epub20__invalid_entity.xml),[4](epubcheckout/4.0.1/epub20__invalid_entity.xml)| |[epub20_encryption_binary_content](build/epub20_encryption_binary_content.epub?raw=true)|2|Encrypted resource with illegal named entity|[3](epubcheckout/3.0.1/epub20_encryption_binary_content.xml),[4](epubcheckout/4.0.1/epub20_encryption_binary_content.xml)| |[epub20_crazy_fixed_layout](build/epub20_crazy_fixed_layout.epub?raw=true)|2|Uses CSS to place each line at fixed position on the page. This results in all sorts of problems after resizing the page and/or font. Valid (but dumb) *EPUB*.|[3](epubcheckout/3.0.1/epub20_crazy_fixed_layout.xml),[4](epubcheckout/4.0.1/epub20_crazy_fixed_layout.xml)| |[epub20_crazy_columns](build/epub20_crazy_columns.epub?raw=true)|2|Uses *style* tags to define columns. Another valid (but dumb) *EPUB*.|[3](epubcheckout/3.0.1/epub20_crazy_columns.xml),[4](epubcheckout/4.0.1/epub20_crazy_columns.xml)| ## How to add a new test file 1. Add uncompressed directory structure to *content* folder 2. Run script to update the builds 3. Add descriptive entry to table above ## License All files here are released under the Creative Commons 3.0 BY-SA license, unless stated otherwise.