Share URL parameters are properly encoded
Why it matters
Social sharing URLs constructed by string concatenation without encodeURIComponent break silently when the page URL or share text contains query parameters, ampersands, hash fragments, or non-ASCII characters. A share button that constructs https://twitter.com/intent/tweet?url=${pageUrl} where pageUrl is /products?id=42&color=red produces a malformed URL: the &color=red portion is interpreted as a second top-level parameter to the tweet intent, not part of the content URL. Per CWE-116, failure to encode output in the correct context causes encoding injection. The user-facing result is a broken share flow: the shared URL navigates to the wrong destination or fails to open entirely.
Severity rationale
Medium because unencoded share URL parameters cause broken share flows for any page URL containing query parameters or special characters, directly affecting social distribution for parameterized routes.
Remediation
Wrap all dynamic values passed into social sharing URL query parameters with encodeURIComponent:
const twitterShareUrl = `https://twitter.com/intent/tweet?url=${encodeURIComponent(pageUrl)}&text=${encodeURIComponent(shareText)}`
const linkedinShareUrl = `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(pageUrl)}`
const facebookShareUrl = `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(pageUrl)}`
Locate all share button components in your src/components/ directory and apply this pattern. Static hardcoded share URLs with no dynamic content do not require encoding.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Social Sharing Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-116 — Improper Encoding or Escaping of Output
Taxons
History
- 2026-04-18·v1.0.0·Initial import from marketing-social-sharing·automated