From 792da18a1eadbe153c848e1065cdd0f73e482437 Mon Sep 17 00:00:00 2001 From: Oskar Eichler <62393985+OskarEichler@users.noreply.github.com> Date: Fri, 28 Aug 2026 03:25:06 +0300 Subject: [PATCH] fix: normalize non-finite dimensions and invalid boolean options --- src/index.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 6ff063a..61be18b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -137,20 +137,25 @@ function validateOptions(input?: CaptureOptions): { const errors: string[] = []; if ( "width" in options && - (typeof options.width !== "number" || options.width <= 0) + (typeof options.width !== "number" || + !Number.isFinite(options.width) || + options.width <= 0) ) { errors.push("option width should be a positive number"); delete options.width; } if ( "height" in options && - (typeof options.height !== "number" || options.height <= 0) + (typeof options.height !== "number" || + !Number.isFinite(options.height) || + options.height <= 0) ) { errors.push("option height should be a positive number"); delete options.height; } if ( typeof options.quality !== "number" || + !Number.isFinite(options.quality) || options.quality < 0 || options.quality > 1 ) { @@ -159,9 +164,12 @@ function validateOptions(input?: CaptureOptions): { } if (typeof options.snapshotContentContainer !== "boolean") { errors.push("option snapshotContentContainer should be a boolean"); + options.snapshotContentContainer = defaultOptions.snapshotContentContainer; } if (typeof options.handleGLSurfaceViewOnAndroid !== "boolean") { errors.push("option handleGLSurfaceViewOnAndroid should be a boolean"); + options.handleGLSurfaceViewOnAndroid = + defaultOptions.handleGLSurfaceViewOnAndroid; } if (acceptedFormats.indexOf(options.format || "") === -1) { const badFormat = options.format;