Media: escape the track label before inserting it into the captions menu - #13252
Closed
bor0 wants to merge 1 commit into
Closed
Media: escape the track label before inserting it into the captions menu#13252bor0 wants to merge 1 commit into
bor0 wants to merge 1 commit into
Conversation
…enu. `MediaElementPlayer.addTrackButton()` concatenated a `<track>` element's `label` into `innerHTML`, so markup in a track label was parsed as HTML. Escape the label so it is always rendered as text. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
MediaElementPlayer.addTrackButton()in the bundled MediaElement builds the captions/subtitles selector by concatenating a<track>element'slabelintoinnerHTML, so markup in a track label is parsed as HTML rather than shown as text. This escapes the label before it is inserted.Change is on the vendored source (
src/js/_enqueues/vendor/mediaelement/mediaelement-and-player.js); thewp-includes/js/mediaelement/copy and the.min.jsare build-generated and not committed here.Why
UI strings should be treated as text. Escaping the label (or, longer term, building the list item with
document.createElement/textContent) keeps a track label from being interpreted as markup.Testing instructions
<track>with alabelattribute containing markup to a video/audio player.Trac ticket
To follow.