Skip to content

Fix invalid EPUB spine references - #54

Open
Ray0907 wants to merge 1 commit into
firecrawl:mainfrom
Ray0907:fix-epub-dangling-spine-itemref
Open

Fix invalid EPUB spine references#54
Ray0907 wants to merge 1 commit into
firecrawl:mainfrom
Ray0907:fix-epub-dangling-spine-itemref

Conversation

@Ray0907

@Ray0907 Ray0907 commented Aug 7, 2026

Copy link
Copy Markdown

Summary

  • Treat EPUB spine entries with missing idref values or dangling manifest references as failed chapters.
  • Return ConvertError::Malformed when every declared spine entry is unusable.
  • Preserve partial recovery when at least one spine chapter remains readable.
  • Add a regression test for a spine entry whose idref is absent from the manifest.

Root cause

Spine entries were collected through filter_map, so malformed or unresolved entries were
silently discarded before the parser's failed-chapter accounting. An EPUB containing only a
dangling spine reference therefore returned an empty successful document instead of a malformed
input error.

Validation

  • cargo test formats::epub::tests::unresolved_spine_itemref_is_malformed -- --exact --nocapture
  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo test --locked

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant