fix: strip spurious default-image-extension from shortcode and empty-URL image sources#14634
Merged
Conversation
…URL image sources Pandoc appends default-image-extension to any extensionless image source at parse time, with no URL guard (confirmed against Pandoc HEAD source). This breaks two cases: - A shortcode used as an image source is parsed without an extension, so Pandoc appends the default. When the shortcode later resolves to a path that already has its own extension, the result carries a doubled extension (e.g. logo.png.png, or logo.png.svg in Typst where the default differs) (#14583). - An extensionless URL ending in a slash gets the extension appended, breaking embed/iframe syntax (#6092). The shortcode case is fixed after the shortcode resolves, where the resolved path is finally known: the appended default extension is stripped only when the resolved path already carries an extension of its own, so the multi-format workflow (a shortcode resolving to an extensionless path) keeps its appended extension. The URL case is fixed in the normalize stage, only for the provably-spurious empty-filename form; a URL with a non-empty last segment is indistinguishable from a real file after parsing and is left untouched.
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This was referenced Jun 29, 2026
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.
Pandoc appends
default-image-extensionto any extensionless image source at parse time. No URL guard exists in Pandoc (confirmed against Pandoc HEAD source). This breaks two cases:) has no extension when parsed, so Pandoc appends the default. When the shortcode later resolves to a path that already has an extension, the result carries a doubled extension (e.g.logo.png.png, orlogo.png.svgin Typst where the default differs from HTML). Reported in Image missing https://quarto.org/docs/computations/python.html#positron #14583; fix(filters): fix include-dark with meta-resolved image paths quarto-web#2086 worked around it locally ininclude-dark.lua.) gets the extension appended, breaking embed/iframe syntax.Fix
The shortcode case is fixed after the shortcode resolves in
shortcodes.lua, where the resolved path is finally known: the appended default extension is stripped only when the resolved path already carries an extension of its own. This preserves the multi-format workflow — a shortcode resolving to an extensionless path (e.g.figures/plot) keeps the appended default so format-specific rendering still works.The URL case is fixed in the normalize stage (
fixupdatauri.lua), only for the provably-spurious empty-filename form (path ends in/.ext). A URL with a non-empty last segment — such ashttps://badgen.net/badge/nameparsed tohttps://badgen.net/badge/name.png— is byte-identical to a real file URL after parsing and is left untouched. The documented workaround (default-image-extension: "") remains for badge-style URLs; a proper fix requires a URI guard upstream in Pandoc.Fixes #14583, related to #6092