Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/149.security.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hardened the `titleSlam` template so title words are rendered through DOM text and `data-text` assignments instead of raw span HTML.
1 change: 1 addition & 0 deletions src/system/templates/_shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { addAdvanceGate } from '../helpers/timing';
// ---------- ctx narrowing (shared with the scene authoring contract) ----

export interface TemplateDomElement {
className?: string;
setAttribute(name: string, value: string): void;
appendChild?(node: unknown): unknown;
textContent?: string;
Expand Down
17 changes: 8 additions & 9 deletions src/system/templates/title-slam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Optional subtitle.

import type { SceneModule } from '../../runtime/scene';
import { markedTextHtml } from '../helpers';
import { buildTemplateScene, buildTemplateTimeline, mountTemplateRoot } from './_shared';

export interface TitleSlamContent {
Expand All @@ -28,14 +27,14 @@ export const titleSlam = (id: string, content: TitleSlamContent): SceneModule =>
templateKind: 'title-slam',
buildChildren: (root, ownerDoc) => {
const h1 = ownerDoc.createElement('h1');
h1.setAttribute('class', 'pulsar-title__h');
const html = words
.map((w) => {
const cls = content.glitch === true ? 'word pulsar-glitch' : 'word';
return `<span class="${cls}" data-text="${w}">${markedTextHtml(w)}</span>`;
})
.join('');
h1.innerHTML = html;
h1.className = 'pulsar-title__h';
for (const w of words) {
const span = ownerDoc.createElement('span');
span.className = content.glitch === true ? 'word pulsar-glitch' : 'word';
span.textContent = w;
span.dataset.text = w;
h1.appendChild?.(span);
}
root.appendChild?.(h1);
if (content.subtitle !== undefined) {
const sub = ownerDoc.createElement('p');
Expand Down
Loading
Loading