Skip to content

fix: prefix raw HTML ids without doubling footnote clobber prefixes - #695

Merged
farnabaz merged 3 commits into
vercel:mainfrom
umeraamir69:fix/sanitize-clobber-prefix-raw-html-ids
Oct 23, 2026
Merged

farnabaz merged 3 commits into
vercel:mainfrom
umeraamir69:fix/sanitize-clobber-prefix-raw-html-ids

Conversation

@umeraamir69

Copy link
Copy Markdown
Contributor

Summary

Fixes #694.

rehype-sanitize was given clobberPrefix: "" so footnote ids from remark-rehype would not become user-content-user-content-fn-1. That also left raw HTML ids unprefixed, so <div id="clobbered"> became window.clobbered.

This restores the default user-content- prefix on sanitize, then a small rehype plugin strips the doubled prefix on ids that remark-rehype already prefixed. Footnote hrefs stay aligned with their targets. Raw HTML ids become #user-content-…. Custom snippet tag tests now expect the prefixed id.

Test plan

  • vitest run on footnotes, allowed-tags, and custom-tag-markdown
  • Confirm a footnote backref still jumps to #user-content-fn-1
  • Confirm raw <div id="clobbered"> does not set window.clobbered

@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

@umeraamir69 is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

✅ All commits are signed

All 3 commit(s) in this pull request have a verified signature. Thanks!

Checked at 60e78cd.

Comment thread packages/streamdown/index.tsx
farnabaz and others added 2 commits October 23, 2026 13:20
Restore user-content- on rehype-sanitize so raw ids cannot clobber window, then strip the doubled prefix on ids remark-rehype already prefixed.

Co-authored-by: Muhammad Umer Aamir <93091750+umeraamir69@users.noreply.github.com>
@farnabaz
farnabaz force-pushed the fix/sanitize-clobber-prefix-raw-html-ids branch from 155a41c to 362601d Compare October 23, 2026 11:22
export const defaultRehypePlugins: Record<string, Pluggable> = {
raw: rehypeRaw,
sanitize: [rehypeSanitize, defaultSanitizeSchema],
undoubleClobberPrefix: rehypeUndoubleClobberPrefix,

@vercel vercel Bot Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Custom pipelines using the documented defaultRehypePlugins.sanitize entry omit normalization, leaving footnote links and backreferences pointing at nonexistent single-prefixed IDs.

Fix on Vercel

@farnabaz farnabaz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks

@farnabaz
farnabaz merged commit 66779a8 into vercel:main Oct 23, 2026
7 of 8 checks passed
@umeraamir69

Copy link
Copy Markdown
Contributor Author

Thanks for the merge farnabaz.

Glad 695 landed today.

I prefixed raw HTML ids after rehype-sanitize dropped clobberPrefix, and I left the footnote user-content- prefix alone so it wouldn't double on issue 694. Ping me if a custom sanitize pipeline still misses a target.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Raw HTML ids reach the DOM unprefixed since clobberPrefix was disabled in rehype-sanitize (2.6.0)

2 participants