Handle percent-encoded EPUB manifest hrefs#2036
Closed
xujiantop-crypto wants to merge 1 commit into
Closed
Conversation
d82279e to
6b98c01
Compare
6b98c01 to
ef179d8
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.
Summary
EPUB manifest
hrefvalues are URI references, so filenames containing spaces or other escaped characters can appear as percent-encoded paths such aschapter%201.xhtml.The current converter compares those raw href values against ZIP member names, which means a valid EPUB containing
OPS/chapter 1.xhtmlcan silently omit the chapter content.This PR resolves manifest hrefs relative to the OPF file and decodes the URI path before matching ZIP members.
Changes
urljoinrelative to the OPF path.href="chapter%201.xhtml"and ZIP memberchapter 1.xhtml.Verification
python -m pytest tests/test_module_vectors.py::test_convert_local[test_vector14] tests/test_module_vectors.py::test_convert_stream_with_hints[test_vector14] tests/test_module_misc.py::test_epub_percent_encoded_manifest_href -qpython -m black --check src/markitdown/converters/_epub_converter.py tests/test_module_misc.pygit diff --checkI also ran broader vector tests locally, but this environment only has core dependencies installed. Vectors requiring optional extras such as
docx,xlsx,pdf, andoutlookfail with missing optional dependency errors unrelated to this EPUB change.