Skip to content

Fix: prevent undisplayable videos from shutting own video sections#4

Open
anirvan wants to merge 2 commits into
masterfrom
fix-ucsf-featured-videos-fails-on-bad-videos
Open

Fix: prevent undisplayable videos from shutting own video sections#4
anirvan wants to merge 2 commits into
masterfrom
fix-ucsf-featured-videos-fails-on-bad-videos

Conversation

@anirvan

@anirvan anirvan commented Jun 15, 2026

Copy link
Copy Markdown
Member

Right now, when users load noembed.com with JSONP, bad videos return raw JSON with a missing Content-Type, rather than a valid text/javascript JSONP function call.

Switching to JSON solves the problem. We don't need JSONP, because the system's CORS headers are okay for a cross-origin GET request

anirvan added 2 commits June 15, 2026 13:24
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