File tree Expand file tree Collapse file tree
caption-editorial-emphasis Expand file tree Collapse file tree Original file line number Diff line number Diff line change 205205
206206 function hfValidate ( data ) {
207207 if ( ! data || typeof data !== "object" ) return { ok : false , reason : "not-an-object" } ;
208- if ( data . version != null && Math . floor ( Number ( data . version ) ) > HF_CONTRACT_VERSION ) {
209- return { ok : false , reason : "unsupported-version" } ;
208+ if ( data . version != null ) {
209+ // Number("v2") is NaN and NaN > x is always false — an explicit
210+ // finite check keeps malformed versions from slipping past the gate.
211+ var hfVersion = Number ( data . version ) ;
212+ if ( ! Number . isFinite ( hfVersion ) || Math . floor ( hfVersion ) > HF_CONTRACT_VERSION ) {
213+ return { ok : false , reason : "unsupported-version" } ;
214+ }
210215 }
211216 if ( ! Array . isArray ( data . segments ) || data . segments . length === 0 ) {
212217 return { ok : false , reason : "no-segments" } ;
679684 var ready =
680685 document . fonts && document . fonts . ready ? document . fonts . ready : Promise . resolve ( ) ;
681686 ready . then ( function ( ) {
687+ // A manual window.__HF_CAPTION_ATTACH__ call that lands while the
688+ // sibling fetch / fonts.ready are still pending must win — never
689+ // clobber it with the late-arriving boot payload.
690+ if ( hfCurrentTimeline ) return ;
682691 hfAttach ( data ) ;
683692 } ) ;
684693 }
Original file line number Diff line number Diff line change 208208
209209 function hfValidate ( data ) {
210210 if ( ! data || typeof data !== "object" ) return { ok : false , reason : "not-an-object" } ;
211- if ( data . version != null && Math . floor ( Number ( data . version ) ) > HF_CONTRACT_VERSION ) {
212- return { ok : false , reason : "unsupported-version" } ;
211+ if ( data . version != null ) {
212+ // Number("v2") is NaN and NaN > x is always false — an explicit
213+ // finite check keeps malformed versions from slipping past the gate.
214+ var hfVersion = Number ( data . version ) ;
215+ if ( ! Number . isFinite ( hfVersion ) || Math . floor ( hfVersion ) > HF_CONTRACT_VERSION ) {
216+ return { ok : false , reason : "unsupported-version" } ;
217+ }
213218 }
214219 if ( ! Array . isArray ( data . segments ) || data . segments . length === 0 ) {
215220 return { ok : false , reason : "no-segments" } ;
790795 var ready =
791796 document . fonts && document . fonts . ready ? document . fonts . ready : Promise . resolve ( ) ;
792797 ready . then ( function ( ) {
798+ // A manual window.__HF_CAPTION_ATTACH__ call that lands while the
799+ // sibling fetch / fonts.ready are still pending must win — never
800+ // clobber it with the late-arriving boot payload.
801+ if ( hfCurrentTimeline ) return ;
793802 hfAttach ( data ) ;
794803 } ) ;
795804 }
Original file line number Diff line number Diff line change 214214
215215 function hfValidate ( data ) {
216216 if ( ! data || typeof data !== "object" ) return { ok : false , reason : "not-an-object" } ;
217- if ( data . version != null && Math . floor ( Number ( data . version ) ) > HF_CONTRACT_VERSION ) {
218- return { ok : false , reason : "unsupported-version" } ;
217+ if ( data . version != null ) {
218+ // Number("v2") is NaN and NaN > x is always false — an explicit
219+ // finite check keeps malformed versions from slipping past the gate.
220+ var hfVersion = Number ( data . version ) ;
221+ if ( ! Number . isFinite ( hfVersion ) || Math . floor ( hfVersion ) > HF_CONTRACT_VERSION ) {
222+ return { ok : false , reason : "unsupported-version" } ;
223+ }
219224 }
220225 if ( ! Array . isArray ( data . segments ) || data . segments . length === 0 ) {
221226 return { ok : false , reason : "no-segments" } ;
491496 var ready =
492497 document . fonts && document . fonts . ready ? document . fonts . ready : Promise . resolve ( ) ;
493498 ready . then ( function ( ) {
499+ // A manual window.__HF_CAPTION_ATTACH__ call that lands while the
500+ // sibling fetch / fonts.ready are still pending must win — never
501+ // clobber it with the late-arriving boot payload.
502+ if ( hfCurrentTimeline ) return ;
494503 hfAttach ( data ) ;
495504 } ) ;
496505 }
Original file line number Diff line number Diff line change 214214
215215 function hfValidate ( data ) {
216216 if ( ! data || typeof data !== "object" ) return { ok : false , reason : "not-an-object" } ;
217- if ( data . version != null && Math . floor ( Number ( data . version ) ) > HF_CONTRACT_VERSION ) {
218- return { ok : false , reason : "unsupported-version" } ;
217+ if ( data . version != null ) {
218+ // Number("v2") is NaN and NaN > x is always false — an explicit
219+ // finite check keeps malformed versions from slipping past the gate.
220+ var hfVersion = Number ( data . version ) ;
221+ if ( ! Number . isFinite ( hfVersion ) || Math . floor ( hfVersion ) > HF_CONTRACT_VERSION ) {
222+ return { ok : false , reason : "unsupported-version" } ;
223+ }
219224 }
220225 if ( ! Array . isArray ( data . segments ) || data . segments . length === 0 ) {
221226 return { ok : false , reason : "no-segments" } ;
599604 var ready =
600605 document . fonts && document . fonts . ready ? document . fonts . ready : Promise . resolve ( ) ;
601606 ready . then ( function ( ) {
607+ // A manual window.__HF_CAPTION_ATTACH__ call that lands while the
608+ // sibling fetch / fonts.ready are still pending must win — never
609+ // clobber it with the late-arriving boot payload.
610+ if ( hfCurrentTimeline ) return ;
602611 hfAttach ( data ) ;
603612 } ) ;
604613 }
Original file line number Diff line number Diff line change 200200
201201 function hfValidate ( data ) {
202202 if ( ! data || typeof data !== "object" ) return { ok : false , reason : "not-an-object" } ;
203- if ( data . version != null && Math . floor ( Number ( data . version ) ) > HF_CONTRACT_VERSION ) {
204- return { ok : false , reason : "unsupported-version" } ;
203+ if ( data . version != null ) {
204+ // Number("v2") is NaN and NaN > x is always false — an explicit
205+ // finite check keeps malformed versions from slipping past the gate.
206+ var hfVersion = Number ( data . version ) ;
207+ if ( ! Number . isFinite ( hfVersion ) || Math . floor ( hfVersion ) > HF_CONTRACT_VERSION ) {
208+ return { ok : false , reason : "unsupported-version" } ;
209+ }
205210 }
206211 if ( ! Array . isArray ( data . segments ) || data . segments . length === 0 ) {
207212 return { ok : false , reason : "no-segments" } ;
616621 var ready =
617622 document . fonts && document . fonts . ready ? document . fonts . ready : Promise . resolve ( ) ;
618623 ready . then ( function ( ) {
624+ // A manual window.__HF_CAPTION_ATTACH__ call that lands while the
625+ // sibling fetch / fonts.ready are still pending must win — never
626+ // clobber it with the late-arriving boot payload.
627+ if ( hfCurrentTimeline ) return ;
619628 hfAttach ( data ) ;
620629 } ) ;
621630 }
You can’t perform that action at this time.
0 commit comments