fix(astro): Fix isHTMLString check failing in multi-realm environments#16142
fix(astro): Fix isHTMLString check failing in multi-realm environments#16142ematipico merged 13 commits intowithastro:mainfrom
isHTMLString check failing in multi-realm environments#16142Conversation
🦋 Changeset detectedLatest commit: e97d963 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
I’ve made a few changes.
|
|
Did you get to see if adding |
|
I just tested this, and confirmed that even if I change
|
|
It seems that HMR not working when editing MDX files is by design, my apologies. |
renderToString during buildisHTMLString check failing in multi-realm environments
|
Just to follow up on the HMR mention, by "HMR," I specifically meant changes being applied without a full page reload. |
.changeset/jolly-ideas-sell.md
Outdated
| 'astro': patch | ||
| --- | ||
|
|
||
| Fix HTML escaping in `renderToString` for MDX slots during build |
There was a problem hiding this comment.
Can you reword the changeset to be more user-centric? https://contribute.docs.astro.build/docs-for-code-changes/changesets/#tips-and-examples
There was a problem hiding this comment.
I've updated the changeset. does this look good to you?
.changeset/jolly-ideas-sell.md
Outdated
| 'astro': patch | ||
| --- | ||
|
|
||
| Fixes HTML content being incorrectly escaped as plain text due to a failed `isHTMLString` check |
There was a problem hiding this comment.
| Fixes HTML content being incorrectly escaped as plain text due to a failed `isHTMLString` check | |
| Fixes HTML content being incorrectly escaped as plain text when rendering a MDX component using the `AstroContainer` APIs. |
cc @rururux for future reference
There was a problem hiding this comment.
I appreciate you tidying that up for me. Thanks for the reference!
|
Thank you! |
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [astro](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/astro)) | [`6.1.1` → `6.1.3`](https://renovatebot.com/diffs/npm/astro/6.1.1/6.1.3) |  |  | --- ### Release Notes <details> <summary>withastro/astro (astro)</summary> ### [`v6.1.3`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#613) [Compare Source](https://github.com/withastro/astro/compare/astro@6.1.2...astro@6.1.3) ##### Patch Changes - [#​16161](withastro/astro#16161) [`b51f297`](withastro/astro@b51f297) Thanks [@​matthewp](https://github.com/matthewp)! - Fixes a dev rendering issue with the Cloudflare adapter where head metadata could be missing and dev CSS/scripts could be injected in the wrong place - [#​16110](withastro/astro#16110) [`de669f0`](withastro/astro@de669f0) Thanks [@​tmimmanuel](https://github.com/tmimmanuel)! - Fixes skew protection query parameters not being appended to inter-chunk JavaScript imports in client bundles, which could cause version mismatches during rolling deployments on Vercel - [#​16162](withastro/astro#16162) [`a0a49e9`](withastro/astro@a0a49e9) Thanks [@​rururux](https://github.com/rururux)! - Fixes an issue where HMR would not trigger when modifying files while using [@​astrojs/cloudflare](https://github.com/astrojs/cloudflare) with prerenderEnvironment: 'node' enabled. - [#​16142](withastro/astro#16142) [`7454854`](withastro/astro@7454854) Thanks [@​rururux](https://github.com/rururux)! - Fixes HTML content being incorrectly escaped as plain text when rendering a MDX component using the `AstroContainer` APIs. - [#​16116](withastro/astro#16116) [`12602a9`](withastro/astro@12602a9) Thanks [@​riderx](https://github.com/riderx)! - Fixes a bug where page-level CSS could leak between unrelated pages when traversing style parents across top-level route boundaries - [#​16178](withastro/astro#16178) [`a7e7567`](withastro/astro@a7e7567) Thanks [@​matthewp](https://github.com/matthewp)! - Fixes SSR builds failing with "No matching renderer found" when a project only has injected routes and no `src/pages/` directory ### [`v6.1.2`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#612) [Compare Source](https://github.com/withastro/astro/compare/astro@6.1.1...astro@6.1.2) ##### Patch Changes - [#​16104](withastro/astro#16104) [`47a394d`](withastro/astro@47a394d) Thanks [@​matthewp](https://github.com/matthewp)! - Fixes `astro preview` ignoring `vite.preview.allowedHosts` set in `astro.config.mjs` - [#​16047](withastro/astro#16047) [`711f837`](withastro/astro@711f837) Thanks [@​matthewp](https://github.com/matthewp)! - Fixes catch-all routes incorrectly intercepting requests for static assets when using the `@astrojs/node` adapter in middleware mode. - [#​15981](withastro/astro#15981) [`a60cbb6`](withastro/astro@a60cbb6) Thanks [@​moktamd](https://github.com/moktamd)! - Fix Zod v4 validation error formatting to show human-readable messages instead of raw JSON </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My45OS4xIiwidXBkYXRlZEluVmVyIjoiNDMuOTkuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> Co-authored-by: Renovate Bot <renovate@zarantonello.dev> Co-committed-by: Renovate Bot <renovate@zarantonello.dev>
fixes: #16003
Changes
When using the Astro Container API, passing child elements to a component inside an MDX file could cause those elements to be incorrectly escaped.
This happened because the
value instanceof HTMLStringcheck in theisHTMLStringfunction failed to recognize theHTMLStringinstance correctly.astro/packages/astro/src/runtime/server/escape.ts
Lines 50 to 52 in 0d24e3b
(
if(isHTMLString(child))does not evaluate to true, so the program proceeds to the nextifstatement)Following Erika’s suggestion, I have updated the logic to check for the presence of
Symbol.for('astro:html-string')instead of usinginstanceof HTMLString.Testing
Added a test to verify that child elements passed to a component inside an MDX file are not incorrectly escaped.
Docs
N/A, bug fix