mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Tests: add case for SVG with truncated embedded PNG
This commit is contained in:
parent
d69c58a6da
commit
cb592ce588
@ -80,7 +80,7 @@
|
||||
"install": "(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)",
|
||||
"clean": "rm -rf node_modules/ build/ vendor/ .nyc_output/ coverage/ test/fixtures/output.*",
|
||||
"test": "semistandard && cpplint && npm run test-unit && npm run test-licensing",
|
||||
"test-unit": "nyc --reporter=lcov --branches=99 mocha --parallel --slow=1000 --timeout=60000 ./test/unit/*.js",
|
||||
"test-unit": "nyc --reporter=lcov --branches=99 mocha --slow=1000 --timeout=60000 ./test/unit/*.js",
|
||||
"test-licensing": "license-checker --production --summary --onlyAllow=\"Apache-2.0;BSD;ISC;MIT\"",
|
||||
"test-coverage": "./test/coverage/report.sh",
|
||||
"test-leak": "./test/leak/leak.sh",
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user