mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #284] [MERGED] Escape closing tags in inline script/style SSR output #443
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#443
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/284
Author: @southpolesteve
Created: 3/6/2026
Status: ✅ Merged
Merged: 3/6/2026
Merged by: @southpolesteve
Base:
main← Head:fix/escape-inline-script-content📝 Commits (1)
b226f52Escape closing tags in inline script/style SSR output📊 Changes
3 files changed (+162 additions, -1 deletions)
View changed files
📝
packages/vinext/src/shims/head.ts(+23 -0)📝
packages/vinext/src/shims/script.tsx(+7 -1)📝
tests/shims.test.ts(+132 -0)📄 Description
Summary
<script>and<style>content rendered during SSR could produce malformed HTML whendangerouslySetInnerHTML.__htmlcontained</script>or</style>sequences. The HTML parser treats these as the end of the containing element regardless of JavaScript/CSS string context, breaking the tag boundary.escapeInlineContent()helper that replaces</scriptand</stylewith<\/scriptand<\/style(case-insensitive). Applied in thenext/scriptbeforeInteractiveSSR path andnext/headreactElementToHTMLfor script/style tags.Changes
packages/vinext/src/shims/head.ts: AddedescapeInlineContent()export. Applied it todangerouslySetInnerHTMLcontent for<script>and<style>tags inreactElementToHTML().packages/vinext/src/shims/script.tsx: ImportedescapeInlineContentand applied it todangerouslySetInnerHTML.__htmlin thebeforeInteractiveSSR path before passing toReact.createElement.tests/shims.test.ts: 14 new tests covering the escaping helper (6 unit tests), Script component SSR (2 integration tests), and Head component SSR (3 integration tests), plus 3 existing tests continue to pass.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.