Skip to content

fix(core): encode spaces in data: URI image targets - #1864

Merged
ggrossetie merged 1 commit into
asciidoctor:mainfrom
ggrossetie:fix/data-uri-image-space-encoding
Jul 25, 2026
Merged

fix(core): encode spaces in data: URI image targets#1864
ggrossetie merged 1 commit into
asciidoctor:mainfrom
ggrossetie:fix/data-uri-image-space-encoding

Conversation

@ggrossetie

Copy link
Copy Markdown
Member

AbstractNode#imageUri() no longer percent-encodes spaces in a data: URI image target (e.g. image::data:image/svg+xml,<svg ...><text>a b</text></svg>[]). This is a regression from the data URI image target support added for inline SVG embedding, which short-circuited imageUri() for any data: target by returning it unchanged — bypassing the space-encoding that normalizeWebPath() still applies to every other URI-ish target.

Upstream Asciidoctor (Ruby) has no data:-specific early return in image_uri at all, so it always encodes spaces via Helpers.encode_spaces_in_uri. imageUri() now runs data: targets through encodeSpacesInUri() before returning them, matching Ruby's output byte-for-byte, while still avoiding the spurious could not retrieve image data from URI warning the earlier fix was meant to prevent.

AbstractNode#imageUri() short-circuited on any data: URI target by
returning it unchanged, added to avoid a spurious "could not retrieve
image data from URI" warning when embedding inline SVGs. That bypassed
the space-encoding that normalizeWebPath() still applies to every other
URI-ish target, and that upstream Asciidoctor (Ruby) also applies since
image_uri has no data:-specific early return. Run data: targets through
encodeSpacesInUri() before returning them so output matches Ruby again.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@ggrossetie
ggrossetie merged commit 8dc9784 into asciidoctor:main Jul 25, 2026
12 checks passed
@ggrossetie
ggrossetie deleted the fix/data-uri-image-space-encoding branch July 25, 2026 21:21
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