Improve error message for SVG render above limit #3167

This commit is contained in:
Lovell Fuller
2022-04-04 14:20:04 +01:00
parent 926572b41e
commit 5d36f5f699
3 changed files with 24 additions and 1 deletions

View File

@@ -136,6 +136,20 @@ describe('SVG input', function () {
assert.strictEqual(info.channels, 4);
});
it('Fails to render SVG larger than 32767x32767', () =>
assert.rejects(
() => sharp(Buffer.from('<svg width="32768" height="1" />')).toBuffer(),
/Input SVG image exceeds 32767x32767 pixel limit/
)
);
it('Fails to render scaled SVG larger than 32767x32767', () =>
assert.rejects(
() => sharp(Buffer.from('<svg width="32767" height="1" />')).resize(32768).toBuffer(),
/Input SVG image will exceed 32767x32767 pixel limit when scaled/
)
);
it('Detects SVG passed as a string', () =>
assert.rejects(
() => sharp('<svg></svg>').toBuffer(),