Skip to content

Fix UCSF featured videos JSON payload escaping in profile page script#3

Open
anirvan wants to merge 1 commit into
masterfrom
fix-ucsf-featured-videos-js-string-escaping
Open

Fix UCSF featured videos JSON payload escaping in profile page script#3
anirvan wants to merge 1 commit into
masterfrom
fix-ucsf-featured-videos-js-string-escaping

Conversation

@anirvan

@anirvan anirvan commented Jun 15, 2026

Copy link
Copy Markdown
Member

UCSFFeaturedVideos currently renders plugin JSON into FeaturedVideos.init('...') using manual backslash and apostrophe replacement. That escaping leaves sequences like ' inside the JSON text seen by JSON.parse(), which causes pages with titles such as "Here's Why" to fail at runtime with JSON.parse: bad escaped character.

Replace the manual string munging with HttpUtility.JavaScriptStringEncode() so the HTML emits a valid JavaScript string literal while preserving the existing client-side contract. FeaturedVideos.js continues to receive a JSON string and parse it as before; only the server-side escaping strategy changes.

This keeps the fix narrowly scoped to UCSFFeaturedVideos and avoids changing database data or the shared video module behavior.

UCSFFeaturedVideos currently renders plugin JSON into FeaturedVideos.init('...') using manual backslash and apostrophe replacement. That escaping leaves sequences like \' inside the JSON text seen by JSON.parse(), which causes pages with titles such as "Here's Why" to fail at runtime with JSON.parse: bad escaped character.

Replace the manual string munging with HttpUtility.JavaScriptStringEncode() so the HTML emits a valid JavaScript string literal while preserving the existing client-side contract. FeaturedVideos.js continues to receive a JSON string and parse it as before; only the server-side escaping strategy changes.

This keeps the fix narrowly scoped to UCSFFeaturedVideos and avoids changing database data or the shared video module behavior.
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.

2 participants