mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Tests: add case for SVG with truncated embedded PNG
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const assert = require('assert');
|
||||
|
||||
const sharp = require('../../');
|
||||
@@ -99,4 +100,18 @@ describe('SVG input', function () {
|
||||
fixtures.assertSimilar(fixtures.expected('svg-embedded.png'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('Converts SVG with truncated embedded PNG', async () => {
|
||||
const truncatedPng = fs.readFileSync(fixtures.inputPngTruncated).toString('base64');
|
||||
const svg = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="294" height="240" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<image width="294" height="240" xlink:href="data:image/png;base64,${truncatedPng}"/>
|
||||
</svg>`;
|
||||
|
||||
const { info } = await sharp(Buffer.from(svg)).toBuffer({ resolveWithObject: true });
|
||||
assert.strictEqual(info.format, 'png');
|
||||
assert.strictEqual(info.width, 294);
|
||||
assert.strictEqual(info.height, 240);
|
||||
assert.strictEqual(info.channels, 4);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user