+ MOBI 7 books are created from one HTML document, and real books' text is read - #403
Merged
Merged
Conversation
Hawkynt
force-pushed
the
feat/mobi-azw-support
branch
from
September 30, 2026 12:25
3b702e2 to
465a4c1
Compare
Hawkynt
force-pushed
the
feat/mobi-azw-support
branch
from
September 30, 2026 14:54
5a97ebf to
e871872
Compare
…xt is read Creation: one UTF-8 HTML input becomes record 0 (PalmDOC header, 232-byte MOBI header, EXTH with title/author/publisher/description/ ISBN/subject, full name), 4096-byte stored or PalmDOC text records, and an end-of-file record. Encryption is refused. Reading: stored and PalmDOC text is decoded into book.html. The text records' trailing entries (extra record data flags: backward-encoded sizes, multibyte overlap) are stripped first. HUFF/CDIC and DRM text stay available as raw records only. The reader had looked for the text encoding, locale and EXTH flags sixteen bytes past where they are, as if the MobileRead offsets were counted from the MOBI magic rather than from record 0. On real books it reported encoding 0xFFFFFFFF and never found EXTH. The first writer on this branch put every field from 0x50 on in the same wrong places, so its round trip passed. Both now use the record-0 offsets, and the full name is read as well. Rung 4 (MobileRead MOBI, PDB and PalmDOC pages); no implementation code consulted. Verified two ways, neither through our own reader: - a calibre 4.17 book (Gutenberg #1065, embedded): book.html equals KindleUnpack 0.4.1's getRawML() byte for byte (SHA-1 recorded), and title, author and encoding are read from their offsets; - our writer's output, stored and PalmDOC, read by KindleUnpack: title, author, codec and the text match. The test runs where CWB_KINDLEUNPACK_PATH points at the python 'mobi' package. The record-0 fields are also asserted directly at the MobileRead offsets for 0, 1, 4096, 4097 and 12288 bytes of text. Trailing-entry, PalmDOC-decoder (malformed input, expansion cap) and encoder round-trip cases cover the boundaries. The package README's corrupted copy from this branch was replaced with main's plus the Mobi row.
Hawkynt
force-pushed
the
feat/mobi-azw-support
branch
from
September 30, 2026 16:07
79fb252 to
5e1a1b4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
book.html, with the text records' trailing entries stripped first (extra record data flags: backward-encoded sizes, multibyte overlap). HUFF/CDIC and DRM text stay raw records only.0xFFFFFFFFand never found EXTH. The first writer on this branch put every field from 0x50 on in the same wrong places, so its self round trip passed. Both are fixed, and the full name is read too.Verification (not through our own reader)
book.htmlequals KindleUnpack 0.4.1'sgetRawML()byte for byte, and title, author, encoding and extra-data flags are read from their offsets.CWB_KINDLEUNPACK_PATHpoints at the pythonmobipackage and is skipped elsewhere. It passed locally.dotnet test --filter Mobi|SupportMatrix|BundledDescriptor|CapabilityDocumentation|RoundTripsItsOwnOutput: 195 passed.Sourcing: rung 4, the MobileRead MOBI, PDB and PalmDOC pages. No implementation code was consulted. KindleUnpack was used only as a black-box oracle.
Not verified: an actual Kindle device or Kindle Previewer. No FLIS, FCIS or index records are written.