Test files › Ebooks › broken-container.epub
Corrupt EPUB file (broken container)
EPUB whose META-INF/container.xml points at an OPF file that does not exist in the archive.
↓ Download broken-container.epub| Filename | broken-container.epub |
| Format | EPUB |
| Size | 1.5 KB (1,516 bytes) |
| MIME type | application/epub+zip |
| SHA-256 | afd0525368dec495c11f8cff4db86c5d0e85b131f6888f1ba328502d12e3a59e |
What this file catchesReaders that trust container.xml without checking the target resolves. A correct reader reports a broken book; a fragile one throws an unhandled error deep in parsing.
Handle it in code
Each snippet below was run against this exact file with Python 3.14.4 and Node 24.15.0 when this page was built, and the output shown is what it printed.
Python
Follow container.xml to the package document and confirm it exists, which is exactly what a reader does first.
import re, zipfile
with zipfile.ZipFile("broken-container.epub") as z:
first = z.infolist()[0]
if first.filename != "mimetype" or first.compress_type != zipfile.ZIP_STORED:
raise SystemExit("rejected: mimetype must be the first entry, stored uncompressed")
container = z.read("META-INF/container.xml").decode("utf-8")
opf = re.search(r'full-path="([^"]+)"', container).group(1)
print("ok" if opf in z.namelist() else f"rejected: container.xml points at {opf}, which is missing")Run against this file, it prints: rejected: container.xml points at OEBPS/missing.opf, which is missing
Related guides and tools
Download & verify
curl -fsSL -o "broken-container.epub" "https://files.hexaqa.com/ebook/broken-container.epub"
curl -fsSL "https://files.hexaqa.com/ebook/broken-container.epub" | sha256sum
# expect: afd0525368dec495c11f8cff4db86c5d0e85b131f6888f1ba328502d12e3a59e