Skip to content

Escape titleSlam data-text attribute instead of composing raw HTML #149

Description

@Brad-Edwards

Review finding

The titleSlam template escapes the visible word content but interpolates the raw word into a data-text attribute in an innerHTML string.

Evidence

  • src/system/templates/title-slam.ts:35 builds <span class="..." data-text="${w}">${markedTextHtml(w)}</span>.
  • markedTextHtml(w) protects the element body, but data-text="${w}" is not attribute-escaped.
  • A title token containing a quote can break out of the data-text attribute and create additional attributes on the generated span.

Impact

Scene modules are trusted today, but L2 templates are content-facing APIs. If generated, imported, or otherwise user-authored deck content reaches this template, a title word can mutate the DOM structure or attach executable attributes.

Recommended fix

Stop constructing these spans with string HTML. Build each span with DOM APIs and assign textContent plus dataset.text / setAttribute() so the browser performs attribute escaping.

Acceptance checks

  • titleSlam creates word spans with ownerDoc.createElement('span'), className / classList, textContent, and an escaped data-text assignment.
  • A test covers a title word containing ", <, and > and proves no additional attributes or elements are created.
  • .pulsar-glitch behavior still has the expected data-text value for CSS rendering.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:renderingDOM/CSS rendering surface, browser support, accessibilitybugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions