Repository navigation
fix(docx-export): embed data-URI images instead of leaking base64 text - #389
Merged
Merged
Conversation
Owner
|
Approved — this fixes the DOCX export path for inline data-URI images by decoding the payload and passing image bytes to add_picture(), so Base64 content is embedded as an image instead of leaking into document text. |
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.
_resolve_image_sourcehandledfile://, http(s), and relative paths, but notdata:URIs. An inline image likefell through to the on-disk path candidates, returned(src, None), and the<img>handler wrote[data:image/png;base64,iVBORw0K...]as the paragraph's literal text — a raw base64 blob visible in the exported DOCX, with no embedded picture.Fix: decode
data:URIs in_resolve_image_source(base64for;base64payloads, URL-unquote otherwise) and return the bytes soadd_picture()embeds the image.Adds
test_data_uri_image_is_embedded_not_leaked_as_text, which failed onmain(the blob appeared as paragraph text andinline_shapeswas empty) and passes here (nodata:text, one inline shape).