Skip to content

fix: strip Sanity Stega zero-width characters from SEO meta tags - #44

Merged
petercr merged 1 commit into
mainfrom
fix/seo-stega-strip
Apr 9, 2026
Merged

fix: strip Sanity Stega zero-width characters from SEO meta tags#44
petercr merged 1 commit into
mainfrom
fix/seo-stega-strip

Conversation

@petercr

@petercr petercr commented Apr 9, 2026

Copy link
Copy Markdown
Owner

Problem

Sanity's Stega encoding injects invisible zero-width Unicode characters into text fields for visual editing overlays. These were leaking into all SEO meta tags — , , , , and the standard \ — causing garbled or polluted social sharing previews.

Additionally, , , , and \ were resolving to \ URLs because \ was not set (fixed separately by setting the env var).

Fix

Added a \ helper in \ that removes characters in the Stega Unicode ranges before values are used in meta tags:

  • U+200B–U+200F (zero-width space, non-joiner, etc.)
  • U+2028–U+202F (line/paragraph separators, narrow no-break space)
  • U+2060–U+2063 (word joiner, invisible characters)
  • U+FEFF (BOM / zero-width no-break space)
  • U+FFF9–U+FFFB (interlinear annotation characters)

Applied to , , and \ before they're inserted into any meta tags.

Verified

Tested on \ — all meta tags now contain clean, human-readable text with no zero-width characters.

Sanity's Stega encoding injects invisible zero-width Unicode characters
into text fields for visual editing overlays. These were leaking into
og:title, og:description, twitter:title, twitter:description, and the
standard meta description — causing garbled social sharing previews.

Added stripStega() helper that removes characters in the Stega Unicode
ranges (U+200B-U+200F, U+2028-U+202F, U+2060-U+2063, U+FEFF,
U+FFF9-U+FFFB) before values are used in meta tags.
@vercel

vercel Bot commented Apr 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ccw Ready Ready Preview, Comment Apr 9, 2026 6:58pm

@petercr
petercr merged commit 1f89b78 into main Apr 9, 2026
3 checks passed
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.

1 participant