mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-11 23:00:03 +00:00
fix(player): reject non-finite composition dimensions from attributes and stage-size (#1205)
width/height attributes went through parseInt with no validation, so a typo like width="abc" reached scaleIframeToFit as NaN (invalid scale(NaN) transform) and width="0" as a division by zero — both blank the player with no signal. The stage-size message check had the sibling gap: `> 0` alone lets Infinity through, which scales the iframe to 0. Reuse the composition probe's readPositiveDimension guard for the attribute path (the probe path already rejected these) and add the same finite-check the adjacent timeline branch uses for stage-size. Mirrors the clampPlaybackRate hardening from #1120. Co-authored-by: Carlos Alcaraz <193642530+calcarazgre646@users.noreply.github.com>
This commit is contained in:
co-authored by
Carlos Alcaraz
parent
937ba2cebe
commit
513819ee84
@@ -36,7 +36,15 @@ export interface ProbeCallbacks {
|
||||
onRuntimeInjected?: () => void;
|
||||
}
|
||||
|
||||
function readPositiveDimension(value: string | null): number | null {
|
||||
/**
|
||||
* Parse a composition dimension, rejecting anything that isn't a positive
|
||||
* finite number. Exported because the `width`/`height` attribute handlers in
|
||||
* hyperframes-player.ts need the same guard: dimensions feed
|
||||
* scaleIframeToFit's `w / compositionWidth` division, where NaN produces an
|
||||
* invalid `scale(NaN)` transform and zero a division by zero — both render
|
||||
* the player blank with no signal.
|
||||
*/
|
||||
export function readPositiveDimension(value: string | null): number | null {
|
||||
if (value === null) return null;
|
||||
const parsed = Number.parseInt(value, 10);
|
||||
return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
|
||||
|
||||
Reference in New Issue
Block a user