Skip to content

Write HTML. Render video. Built for agents.

fix(registry): reject non-numeric caption-data versions; boot fetch never clobbers a manual attach

vanceingalls5c2981d06648
diff --git a/registry/components/caption-editorial-emphasis/caption-editorial-emphasis.html b/registry/components/caption-editorial-emphasis/caption-editorial-emphasis.html
index 83f808425a..3790946ee0 100644
--- a/registry/components/caption-editorial-emphasis/caption-editorial-emphasis.html
+++ b/registry/components/caption-editorial-emphasis/caption-editorial-emphasis.html
@@ -205,8 +205,13 @@
function hfValidate(data) {
if (!data || typeof data !== "object") return { ok: false, reason: "not-an-object" };
- if (data.version != null && Math.floor(Number(data.version)) > HF_CONTRACT_VERSION) {
- return { ok: false, reason: "unsupported-version" };
+ if (data.version != null) {
+ // Number("v2") is NaN and NaN > x is always false — an explicit
+ // finite check keeps malformed versions from slipping past the gate.
+ var hfVersion = Number(data.version);
+ if (!Number.isFinite(hfVersion) || Math.floor(hfVersion) > HF_CONTRACT_VERSION) {
+ return { ok: false, reason: "unsupported-version" };
+ }
}
if (!Array.isArray(data.segments) || data.segments.length === 0) {
return { ok: false, reason: "no-segments" };
@@ -679,6 +684,10 @@
var ready =
document.fonts && document.fonts.ready ? document.fonts.ready : Promise.resolve();
ready.then(function () {
+ // A manual window.__HF_CAPTION_ATTACH__ call that lands while the
+ // sibling fetch / fonts.ready are still pending must win — never
+ // clobber it with the late-arriving boot payload.
+ if (hfCurrentTimeline) return;
hfAttach(data);
});
}
diff --git a/registry/components/caption-emoji-pop/caption-emoji-pop.html b/registry/components/caption-emoji-pop/caption-emoji-pop.html
index 6d6f15c697..7c982e2781 100644
--- a/registry/components/caption-emoji-pop/caption-emoji-pop.html
+++ b/registry/components/caption-emoji-pop/caption-emoji-pop.html
@@ -208,8 +208,13 @@
function hfValidate(data) {
if (!data || typeof data !== "object") return { ok: false, reason: "not-an-object" };
- if (data.version != null && Math.floor(Number(data.version)) > HF_CONTRACT_VERSION) {
- return { ok: false, reason: "unsupported-version" };
+ if (data.version != null) {
+ // Number("v2") is NaN and NaN > x is always false — an explicit
+ // finite check keeps malformed versions from slipping past the gate.
+ var hfVersion = Number(data.version);
+ if (!Number.isFinite(hfVersion) || Math.floor(hfVersion) > HF_CONTRACT_VERSION) {
+ return { ok: false, reason: "unsupported-version" };
+ }
}
if (!Array.isArray(data.segments) || data.segments.length === 0) {
return { ok: false, reason: "no-segments" };
@@ -790,6 +795,10 @@
var ready =
document.fonts && document.fonts.ready ? document.fonts.ready : Promise.resolve();
ready.then(function () {
+ // A manual window.__HF_CAPTION_ATTACH__ call that lands while the
+ // sibling fetch / fonts.ready are still pending must win — never
+ // clobber it with the late-arriving boot payload.
+ if (hfCurrentTimeline) return;
hfAttach(data);
});
}
diff --git a/registry/components/caption-highlight/caption-highlight.html b/registry/components/caption-highlight/caption-highlight.html
index b87f407e84..a1d1b8be96 100644
--- a/registry/components/caption-highlight/caption-highlight.html
+++ b/registry/components/caption-highlight/caption-highlight.html
@@ -214,8 +214,13 @@
function hfValidate(data) {
if (!data || typeof data !== "object") return { ok: false, reason: "not-an-object" };
- if (data.version != null && Math.floor(Number(data.version)) > HF_CONTRACT_VERSION) {
- return { ok: false, reason: "unsupported-version" };
+ if (data.version != null) {
+ // Number("v2") is NaN and NaN > x is always false — an explicit
+ // finite check keeps malformed versions from slipping past the gate.
+ var hfVersion = Number(data.version);
+ if (!Number.isFinite(hfVersion) || Math.floor(hfVersion) > HF_CONTRACT_VERSION) {
+ return { ok: false, reason: "unsupported-version" };
+ }
}
if (!Array.isArray(data.segments) || data.segments.length === 0) {
return { ok: false, reason: "no-segments" };
@@ -491,6 +496,10 @@
var ready =
document.fonts && document.fonts.ready ? document.fonts.ready : Promise.resolve();
ready.then(function () {
+ // A manual window.__HF_CAPTION_ATTACH__ call that lands while the
+ // sibling fetch / fonts.ready are still pending must win — never
+ // clobber it with the late-arriving boot payload.
+ if (hfCurrentTimeline) return;
hfAttach(data);
});
}
diff --git a/registry/components/caption-pill-karaoke/caption-pill-karaoke.html b/registry/components/caption-pill-karaoke/caption-pill-karaoke.html
index 341400fb80..c0025e2629 100644
--- a/registry/components/caption-pill-karaoke/caption-pill-karaoke.html
+++ b/registry/components/caption-pill-karaoke/caption-pill-karaoke.html
@@ -214,8 +214,13 @@
function hfValidate(data) {
if (!data || typeof data !== "object") return { ok: false, reason: "not-an-object" };
- if (data.version != null && Math.floor(Number(data.version)) > HF_CONTRACT_VERSION) {
- return { ok: false, reason: "unsupported-version" };
+ if (data.version != null) {
+ // Number("v2") is NaN and NaN > x is always false — an explicit
+ // finite check keeps malformed versions from slipping past the gate.
+ var hfVersion = Number(data.version);
+ if (!Number.isFinite(hfVersion) || Math.floor(hfVersion) > HF_CONTRACT_VERSION) {
+ return { ok: false, reason: "unsupported-version" };
+ }
}
if (!Array.isArray(data.segments) || data.segments.length === 0) {
return { ok: false, reason: "no-segments" };
@@ -599,6 +604,10 @@
var ready =
document.fonts && document.fonts.ready ? document.fonts.ready : Promise.resolve();
ready.then(function () {
+ // A manual window.__HF_CAPTION_ATTACH__ call that lands while the
+ // sibling fetch / fonts.ready are still pending must win — never
+ // clobber it with the late-arriving boot payload.
+ if (hfCurrentTimeline) return;
hfAttach(data);
});
}
diff --git a/registry/components/caption-weight-shift/caption-weight-shift.html b/registry/components/caption-weight-shift/caption-weight-shift.html
index f2c42f10ff..d6340fd6a2 100644
--- a/registry/components/caption-weight-shift/caption-weight-shift.html
+++ b/registry/components/caption-weight-shift/caption-weight-shift.html
@@ -200,8 +200,13 @@
function hfValidate(data) {
if (!data || typeof data !== "object") return { ok: false, reason: "not-an-object" };
- if (data.version != null && Math.floor(Number(data.version)) > HF_CONTRACT_VERSION) {
- return { ok: false, reason: "unsupported-version" };
+ if (data.version != null) {
+ // Number("v2") is NaN and NaN > x is always false — an explicit
+ // finite check keeps malformed versions from slipping past the gate.
+ var hfVersion = Number(data.version);
+ if (!Number.isFinite(hfVersion) || Math.floor(hfVersion) > HF_CONTRACT_VERSION) {
+ return { ok: false, reason: "unsupported-version" };
+ }
}
if (!Array.isArray(data.segments) || data.segments.length === 0) {
return { ok: false, reason: "no-segments" };
@@ -616,6 +621,10 @@
var ready =
document.fonts && document.fonts.ready ? document.fonts.ready : Promise.resolve();
ready.then(function () {
+ // A manual window.__HF_CAPTION_ATTACH__ call that lands while the
+ // sibling fetch / fonts.ready are still pending must win — never
+ // clobber it with the late-arriving boot payload.
+ if (hfCurrentTimeline) return;
hfAttach(data);
});
}