fix(docx): extract image ref from <a:blip> when it contains child elements#591
Merged
Goldziher merged 1 commit intokreuzberg-dev:mainfrom Mar 27, 2026
Merged
Conversation
When Word saves a document with high-quality image settings, it adds an <a:extLst> child element inside <a:blip>, making the XML parser emit Event::Start instead of Event::Empty for that tag. The image reference (r:embed) is an attribute on the opening tag, so it must be read in the Start arm too — not only in the Empty arm. Fixes kreuzberg-dev#590 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
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.
Problem
Fixes #590
When Word generates a DOCX with certain image settings (e.g. high-quality print output), it adds an
<a:extLst>child inside<a:blip>:Because the element now has children,
quick-xmlemitsEvent::Startinstead ofEvent::Empty. The image referencer:embedis an attribute on the opening tag — but the code only handledblipin theEvent::Emptyarm, soimage_refwas never populated, images were silently skipped, andresult.imagesreturnedNone.Fix
Added
b"blip"to theEvent::Startmatch arm inparse_drawing()so ther:embed/r:linkattribute is read regardless of whether the element is self-closing or has children.Testing
test_parse_blip_with_extlst_childrenreproducing the exact XML structure from a real-world DOCX that originally triggered the bugextraction::docx::drawingtests pass:cargo test -p kreuzberg --lib --features office -- extraction::docx::drawingresult.images = None; after — a 399 KB JPEG (680×951 px) is correctly returned inresult.images