Skip to content

Media: escape the track label before inserting it into the captions menu - #13252

Closed
bor0 wants to merge 1 commit into
WordPress:trunkfrom
bor0:fix/mediaelement-escape-track-label
Closed

Media: escape the track label before inserting it into the captions menu#13252
bor0 wants to merge 1 commit into
WordPress:trunkfrom
bor0:fix/mediaelement-escape-track-label

Conversation

@bor0

@bor0 bor0 commented Aug 24, 2026

Copy link
Copy Markdown
Member

Summary

MediaElementPlayer.addTrackButton() in the bundled MediaElement builds the captions/subtitles selector by concatenating a <track> element's label into innerHTML, 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); the wp-includes/js/mediaelement/ copy and the .min.js are 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

  • Add a <track> with a label attribute containing markup to a video/audio player.
  • Open the captions/subtitles menu; the label now appears as literal text rather than being parsed as HTML.

Trac ticket

To follow.

…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>
@bor0 bor0 closed this Aug 24, 2026
@bor0
bor0 deleted the fix/mediaelement-escape-track-label branch August 24, 2026 15:21
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.

1 participant