Fix: prevent undisplayable videos from shutting own video sections#4
Open
anirvan wants to merge 2 commits into
Open
Fix: prevent undisplayable videos from shutting own video sections#4anirvan wants to merge 2 commits into
anirvan wants to merge 2 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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