Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions packages/solid-router/src/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,22 @@ export function useLinkProps<
}
return _href.href
}
const to = _options().to
const isSafeInternal =
typeof to === 'string' &&
to.charCodeAt(0) === 47 && // '/'
to.charCodeAt(1) !== 47 // but not '//'
if (isSafeInternal) return undefined
try {
new URL(_options().to as any)
new URL(to as any)
// Block dangerous protocols like javascript:, data:, vbscript:
if (isDangerousProtocol(_options().to as string)) {
if (isDangerousProtocol(to as string)) {
if (process.env.NODE_ENV !== 'production') {
console.warn(`Blocked Link with dangerous protocol: ${_options().to}`)
console.warn(`Blocked Link with dangerous protocol: ${to}`)
}
return undefined
}
return _options().to
return to
} catch {}
return undefined
})
Expand Down
Loading