mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #597] [MERGED] fix: validate attribute names in next/head SSR serializer #697
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#697
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/597
Author: @southpolesteve
Created: 3/19/2026
Status: ✅ Merged
Merged: 3/20/2026
Merged by: @southpolesteve
Base:
main← Head:fix/sanitize-head-attr-names📝 Commits (1)
f77068cfix: validate attribute names in next/head SSR serializer📊 Changes
2 files changed (+90 additions, -0 deletions)
View changed files
📝
packages/vinext/src/shims/head.ts(+20 -0)📝
tests/shims.test.ts(+70 -0)📄 Description
Summary
escapeAttr().isSafeAttrName()that validates attribute names against a strict regex (alphanumeric, hyphens, colons, dots) and blocks inline event handler attributes (on*).reactElementToHTML()path and the client-sidesyncClientHead()path.Details
Previously, attribute names from React element props were used verbatim in the SSR HTML output. If application code spread an object with arbitrary keys onto a JSX element inside
<Head>, those keys would appear unescaped in the rendered HTML. The new validation rejects names containing characters that could break the attribute context (<,>,",/,=, spaces) and blockson*event handler attributes.Standard HTML attributes like
name,content,http-equiv,data-*, and XML-namespaced attributes likexml:langcontinue to work normally.Also adds unit tests covering allowed names, rejected names, event handlers, and edge cases.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.