fix(metadata): ensure EPUB version-aware metadata writing#2998
Draft
Shaglock wants to merge 1 commit intobooklore-app:developfrom
Draft
fix(metadata): ensure EPUB version-aware metadata writing#2998Shaglock wants to merge 1 commit intobooklore-app:developfrom
Shaglock wants to merge 1 commit intobooklore-app:developfrom
Conversation
EpubMetadataWriter unconditionally wrote EPUB3-only constructs into all EPUB files regardless of version, producing invalid OPF documents for EPUB3 files (e.g. opf:file-as/opf:role attributes on dc:creator) and writing EPUB3-only elements into EPUB2 files. Changes: - createCreatorElement: EPUB3 uses <meta refines="#id"> for file-as/role; EPUB2 uses opf: attributes on dc:creator - addFolderContentsToZip: mimetype is now STORED (uncompressed) and written as the first ZIP entry per EPUB spec - replaceBelongsToCollection: EPUB3 uses belongs-to-collection with refines; EPUB2 uses calibre:series/calibre:series_index convention - addSubtitleToTitle: EPUB3 uses separate dc:title with title-type refinement; EPUB2 stores subtitle via booklore:subtitle metadata only - addBookloreMetadata/createBookloreMetaElement: EPUB3 uses property attribute with prefix; EPUB2 uses name/content attribute form - removeAllBookloreMetadata: now handles both EPUB3 property and EPUB2 name attributes - cleanupCalibreArtifacts: preserves calibre:series and calibre:series_index metas used for EPUB2 series - organizeMetadataElements: correctly categorizes EPUB2-style series and booklore metas into their respective buckets - addBookloreMetadata: writes booklore:subtitle for round-trip fidelity - Added isEpub3() helper method Closes booklore-app#2997
Collaborator
|
Hi, thank you for your submission. Please note that we require all PRs to use our standard message template and include proof of task completion. Could you please update your PR description to meet these guidelines? Thanks! |
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.
Summary
Fixes #2997
EpubMetadataWriterunconditionally wrote EPUB3-only constructs into all EPUB files regardless of version. This produced invalid OPF documents that fail Amazon's Send to Kindle validation (error E999) and epubcheck validation (RSC-005,PKG-007).Root Cause
When Booklore modifies EPUB metadata, it always wrote EPUB3 constructs (e.g.,
opf:file-as/opf:roleattributes ondc:creator,<meta property="...">elements,prefixattribute on<package>) regardless of whether the EPUB is version 2.0 or 3.0. For EPUB3 files, usingopf:attributes ondc:creatoris invalid per the spec — EPUB3 requires<meta refines="#id">elements instead.Changes
All changes are in
EpubMetadataWriter.java(source) andEpubMetadataWriterTest.java(tests):createCreatorElement: EPUB3 now uses<meta refines="#id">forfile-asandrolewithmarc:relatorsscheme; EPUB2 keepsopf:attributes ondc:creatoraddFolderContentsToZip:mimetypeis now STORED (uncompressed) and written as the first ZIP entry per EPUB specreplaceBelongsToCollection: EPUB3 usesbelongs-to-collectionwith refines; EPUB2 usescalibre:series/calibre:series_indexconvention (widely supported by e-readers)addSubtitleToTitle: EPUB3 uses separatedc:titlewithtitle-typerefinement; EPUB2 stores subtitle viabooklore:subtitlemetadata only (preserves round-trip fidelity)addBookloreMetadata/createBookloreMetaElement: EPUB3 usespropertyattribute withprefix; EPUB2 usesname/contentattribute form. Also now writesbooklore:subtitlefor extraction round-trip.removeAllBookloreMetadata: Now handles both EPUB3propertyand EPUB2nameattributescleanupCalibreArtifacts: Preservescalibre:seriesandcalibre:series_indexmetas (used for EPUB2 series)organizeMetadataElements: Correctly categorizes EPUB2-style series and booklore metas into their respective bucketsisEpub3()helper method used throughoutVerification
Verified with epubcheck v5.3.0 — EPUB3 files modified by Booklore now produce 0 errors, 0 warnings.
Test Output
All 2570+ existing tests pass. 14 new tests added covering: