From 7d4ad1cc2ac83509540a678f30a76caf127611ee Mon Sep 17 00:00:00 2001 From: metsw24-max Date: Tue, 23 Jun 2026 17:29:03 +0530 Subject: [PATCH] reject non-finite numbers in is.number --- lib/is.mjs | 2 +- test/unit/affine.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/is.mjs b/lib/is.mjs index bfb4188f8..c3e201200 100644 --- a/lib/is.mjs +++ b/lib/is.mjs @@ -78,7 +78,7 @@ const string = (val) => typeof val === 'string' && val.length > 0; * Is this value a real number? * @private */ -const number = (val) => typeof val === 'number' && !Number.isNaN(val); +const number = (val) => typeof val === 'number' && Number.isFinite(val); /** * Is this value an integer? diff --git a/test/unit/affine.js b/test/unit/affine.js index ab662f878..5ae477bf7 100644 --- a/test/unit/affine.js +++ b/test/unit/affine.js @@ -73,6 +73,20 @@ suite('Affine transform', () => { .affine([[4, 4], [4, 4]], { ody: 'invalid ody type' }); }); }); + test('Non-finite idx offset', (t) => { + t.plan(1); + t.assert.throws(() => { + sharp(fixtures.inputJpg) + .affine([[4, 4], [4, 4]], { idx: Infinity }); + }); + }); + test('Non-finite idy offset', (t) => { + t.plan(1); + t.assert.throws(() => { + sharp(fixtures.inputJpg) + .affine([[4, 4], [4, 4]], { idy: -Infinity }); + }); + }); test('Invalid interpolator', (t) => { t.plan(1); t.assert.throws(() => {