Repository navigation
Conversation
Astro 7.1.3 escaped an `&` in a Markdown image's alt or title text twice (`alt="Tom &amp; Jerry"`), so img.alt held a literal `&` and screen readers read it out. Astro 7.3.4 fixed this (withastro/astro#18086). This upgrades astro to 7.4.5 and @astrojs/mdx to 8.1.2, which pin the same Sätteri release. tests/attribute-escaping.test.ts fails when a built page escapes an attribute value twice. It also builds a throwaway Astro project to check that alt and title text in .md and .mdx images keeps every ASCII punctuation character. On 7.4.5 a backtick in .md image text still comes out as ```, so AGENTS.md keeps backticks out of image text, and it.fails canaries flag the release that fixes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Review of e288e93 found that the built-pages scan flagged valid serialized data (astro-island props holding `&`, data-* attributes), missed named references outside its short list (`&copy;`), matched misspelled ones (`&aMp;`) and skipped `<noscript>` markup. The backtick canaries also passed when an image lost its alt or title. - Scan only attributes that hold text or URLs, and flag a value when entities' decodeHTMLAttribute would change it, which follows the browser's own reference rules. Parse with scripting on and off. - Add self-tests that pin the scan's behavior on each case above. - Pin the known .md backtick value `Back`tick` in place of it.fails, and check that public/ and remote images, which Astro doesn't process, keep backticks, and that code span backticks drop out of alt text. - Qualify the AGENTS.md backtick rule to processed images; the rule still covers every .md image. - Declare entities ^7.0.1 as a dev dependency; the tree already held it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch was successfully deployed
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.
Draft until the review of this head agrees.
Problem
Markdown images run through a round trip in Astro: the image's props go into a
__ASTRO_IMAGE_placeholder attribute as JSON, Astro decodes some character references in it, parses the JSON, and escapes the values again for the final<img>. Any reference the decode step misses gets escaped a second time, and the browser then shows it as text. For an image's alt text, a screen reader reads the reference out.", so an apostrophe came out asalt="…forecasters&#x27; average…"(reported on the dev server on 2026-11-04).&still comes out asalt="Tom &amp; Jerry".Change
astro^7.1.3 → ^7.4.5 and@astrojs/mdx^7.0.3 → ^8.1.2. Both pin@astrojs/markdown-satteri0.4.6, so the tree holds one Sätteri copy. MDX 8's one breaking change only affects sites that setmarkdown.processor, and this site doesn't. All three releases carry npm SLSA provenance.parse5^7.3.0 andentities^7.0.1 as dev dependencies. Both already sat in the tree (entitiesthrough happy-dom), so the lockfile adds no packages.tests/attribute-escaping.test.ts:dist/**/*.html, once with scripting on and once with it off so that<noscript>markup counts. It fails if any text or URL attribute (alt,title, ARIA labels,placeholder,<meta>content,href,src,srcsetand similar) would change if decoded a second time, which means the build escaped it twice.entities'decodeHTMLAttributeapplies the browser's own rules, so it recognizes every named and numeric reference and ignores misspelled ones such as&aMp;. The scan skips serialized data, such as astro-island props anddata-*attributes, which can hold references legitimately.&copy;),<noscript>markup, a misspelled reference, island props and adata-*attribute..md, a content collection.mdxand asrc/pages.mdfile. Each holds images whose alt and title text cover the reported apostrophe,&, quotes,</>, literal entity text, non-ASCII text (NBSP, emoji) and every ASCII punctuation character. The test requires each decoded alt and title to equal its source text. Each file also holds a backtick in a processed image, apublic/image and a remote image, plus a code span in alt text. The fixture keeps Astro's and Vite's caches in its own folder, so it never writes into the site'snode_modules.AGENTS.md: documents the test, and adds a rule to keep literal backticks out of.mdimage alt and title text (below).Invariants the test checks
vin the built site,decodeHTMLAttribute(v) === v: the browser's single decode leaves no character reference behind.s, the builtimghasalt === sandtitle === s..mdimage renders asBack`tick(today's known bug, pinned). It survives in MDX, inpublic/images and in remote images, and code span backticks drop out of alt text.Remaining upstream gap: backticks
On 7.4.5, a literal backtick in
.mdimage text still comes out as`. Sätteri writes`as`in attributes, and Astro's decode chain (still the same onmain) handles only quote, apostrophe and ampersand references. That round trip covers only images Astro processes: relative paths, plus remote hosts that theimageconfig allows (this site allows none).public/images, other remote images and MDX keep backticks intact. I tested every ASCII punctuation character plus NBSP, soft hyphen, zero-width space, emoji, tab and U+2028, one alt each, and only the backtick fails. Until Astro fixes it:AGENTS.mdkeeps literal backticks out of all.mdimage text, since an image can move frompublic/to a relative path. Backticks that pair into a code span drop out of alt text, so those are fine..mdvalueBack`tick, so its checks fail in the release that fixes this, and also if the attribute goes missing.What else the upgrade changes in the built site
I diffed every HTML, XML, text and JSON file in clean builds of master (7.1.3) and this branch (7.4.5), 301 HTML files each. After normalizing asset hashes, scoped-style ids, whitespace, inline scripts, empty
srcsetattributes and islanduidvalues, one file differs:voter-guides/2022-11-california/prop-1/. In that guide, a closing quote after a period (procedure.") rendered as an opening quote“on 7.1.3 and now renders correctly as”. The normalization hides four more changes:srcset=""(18 on master, none now).usage/,mackenzie-scott-qaly/,blog/double-eye-contact/and its crosspost) get newastro-islanduidvalues. The islands hydrated in a local preview with no console errors._astro/rolldown-runtime.*.jschunk appears.Verification
vitest run tests/attribute-escaping.test.ts→ 30 passed.): 5 failed, 25 passed. The built-pages scan flagsalt="Tom & Jerry’s alt"on the probe page and its crosspost, and the fixture fails alt and title on both.mdpaths. MDX passes.bun run build,astro check(0 errors) andtsc --noEmitpass locally.🤖 Generated with Claude Code