Skip to content

Commit 8b6f09e

Browse files
committed
fix(slideshow): address PR review + CodeQL findings
- CodeQL #638 (parseSlideshow): complete the regex metachar escape in slideshowIslandRegex (was missing backslash); add JSDoc on the factory + lastIndex caveat (reviewer 5a/16). - CodeQL #639/#640 + review items 13/17: remove registry/examples/airbnb-deck/ presenter-test.html — a generated test harness (postMessage w/o origin check, proto-pollution) that was scope-creep into a fix PR and a 3rd duplicate island. Regenerate locally via the scratchpad script when testing. - Review item 15 (docs drift in skills/slideshow/SKILL.md): lint resolves scenes by data-composition-id only (not .clip[id]); fragments are valid INCLUSIVE of [start,end], not 'strictly inside'. IIFE bundles core confirmed (0 external @hyperframes/core refs in the slideshow global build). format/lint/fallow green.
1 parent 32996ed commit 8b6f09e

3 files changed

Lines changed: 21 additions & 234 deletions

File tree

‎packages/core/src/slideshow/parseSlideshow.ts‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@ import type {
99

1010
export const SLIDESHOW_ISLAND_TYPE = "application/hyperframes-slideshow+json";
1111

12-
/** Builds the island <script> matcher. Capture group 1 = inner JSON. */
12+
/**
13+
* Builds the island <script> matcher. Capture group 1 = inner JSON.
14+
*
15+
* Factory (fresh RegExp per call) on purpose: a RegExp with the `g` flag carries
16+
* a mutable `lastIndex`, so callers that need `g` must call this each time rather
17+
* than caching a shared instance.
18+
*/
1319
export function slideshowIslandRegex(flags = "i"): RegExp {
14-
return new RegExp(
15-
`<script[^>]*type=["']${SLIDESHOW_ISLAND_TYPE.replace(/[.+]/g, "\\$&")}["'][^>]*>([\\s\\S]*?)<\\/script>`,
16-
flags,
17-
);
20+
// Escape ALL regex metacharacters in the constant (CodeQL flags the incomplete
21+
// `\` escape). The constant has none today, but a complete escape is correct.
22+
const escaped = SLIDESHOW_ISLAND_TYPE.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
23+
return new RegExp(`<script[^>]*type=["']${escaped}["'][^>]*>([\\s\\S]*?)<\\/script>`, flags);
1824
}
1925

2026
interface SceneRange {

‎registry/examples/airbnb-deck/presenter-test.html‎

Lines changed: 0 additions & 219 deletions
This file was deleted.

‎skills/slideshow/SKILL.md‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ The island is the single source of truth for slide order, notes, fragment hold-p
8585
}
8686
```
8787

88-
| Field | Required | Notes |
89-
| ------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------- |
90-
| `sceneId` | yes | Must match a scene's `data-composition-id` exactly. The lint rule resolves both `data-composition-id` and `.clip[id]`. |
91-
| `notes` | no | Presenter-only text. Never shown to the audience. |
92-
| `fragments` | no | Array of times (seconds) within the slide's `[start, end]` range — see Fragments below. |
93-
| `hotspots` | no | Interactive overlays that trigger a branch — see Branching below. |
94-
| `startTime` | no | Optional. Override the matched scene's time bounds; defaults to the scene's start/end. |
95-
| `endTime` | no | Optional. Override the matched scene's time bounds; defaults to the scene's start/end. |
96-
| `ttsScript`, `ttsAudioUrl`, `ttsDurationMs` | no | **Reserved.** Schema fields exist but TTS playback is not yet wired. Omit unless you are pre-populating for a future build. |
88+
| Field | Required | Notes |
89+
| ------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
90+
| `sceneId` | yes | Must match a scene's `data-composition-id` exactly (or provide explicit `startTime`/`endTime`). The lint rule resolves scenes by `data-composition-id`. |
91+
| `notes` | no | Presenter-only text. Never shown to the audience. |
92+
| `fragments` | no | Array of times (seconds) within the slide's `[start, end]` range — see Fragments below. |
93+
| `hotspots` | no | Interactive overlays that trigger a branch — see Branching below. |
94+
| `startTime` | no | Optional. Override the matched scene's time bounds; defaults to the scene's start/end. |
95+
| `endTime` | no | Optional. Override the matched scene's time bounds; defaults to the scene's start/end. |
96+
| `ttsScript`, `ttsAudioUrl`, `ttsDurationMs` | no | **Reserved.** Schema fields exist but TTS playback is not yet wired. Omit unless you are pre-populating for a future build. |
9797

9898
### `SlideHotspot`
9999

@@ -151,7 +151,7 @@ A fragment is a time (in seconds) within a slide's `[start, end]` range where th
151151
4. After the last fragment, Next plays to `slide.end` and holds.
152152
5. Next again advances to the next slide.
153153

154-
Fragment times must be strictly inside `[start, end]`. The lint rule rejects fragments outside that range.
154+
Fragment times must fall within `[start, end]` (inclusive of both bounds). The lint rule rejects only fragments outside that range (`time < start` or `time > end`).
155155

156156
Fragment times are **absolute composition-timeline positions** — the same coordinate space as `data-start` — not offsets relative to the scene's start.
157157

0 commit comments

Comments
 (0)