mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #174] [MERGED] fix: block dangerous URI schemes in Link and Form components #369
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#369
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/174
Author: @southpolesteve
Created: 2/27/2026
Status: ✅ Merged
Merged: 2/27/2026
Merged by: @southpolesteve
Base:
main← Head:fix/block-dangerous-uri-schemes-in-link-form📝 Commits (1)
1194ab0fix: block dangerous URI schemes in Link and Form components📊 Changes
3 files changed (+61 additions, -0 deletions)
View changed files
📝
packages/vinext/src/shims/form.tsx(+31 -0)📝
packages/vinext/src/shims/link.tsx(+13 -0)➕
packages/vinext/src/shims/url-safety.ts(+17 -0)📄 Description
Summary
Validates URL schemes in the
LinkandFormcomponent shims to match how Next.js handles these cases. Blocksjavascript:,data:, andvbscript:URI schemes that should never appear in navigation targets.Changes
New:
url-safety.ts-- sharedisDangerousScheme()utility with a single regex that handles evasion vectors (mixed case, leading whitespace, zero-width characters, whitespace before colon).Link component (
link.tsx)isDangerousScheme()before rendering<a>withouthref(preserves className, id, aria-* for styling)console.warnForm component (
form.tsx)isSafeAction()validates string action URLs//evil.com), and cross-origin absolute URLsactionattribute (submits to current page)Based on the work by @kochrac in #142. This PR takes a different approach (validating at the component level rather than escaping in code generation) since the generated entries are Vite virtual modules, not inline HTML.
Supersedes #142
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.