Skip to content

Commit

Permalink
svg: fix "push after EOF" error (#53)
Browse files Browse the repository at this point in the history
Co-authored-by: Michal <sudolskym@gmail.com>
  • Loading branch information
misos1 and Michal committed Mar 18, 2021
1 parent 61cf9b2 commit 5aa8410
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/parse_stream/svg.js
Expand Up @@ -160,6 +160,7 @@ module.exports = function () {
var result = parseSvg(str);

if (result) {
state = STATE_IGNORE;
parser.push(result);
parser.push(null);
break;
Expand Down
12 changes: 12 additions & 0 deletions test/test_stream.js
Expand Up @@ -95,4 +95,16 @@ describe('probeStream', function () {
/unrecognized file format/
);
});

it('should not fail when processing svg in multiple chunks', async function () {
let stream = new Readable({
read: function () {
this.push('<?xml version="1.0" encoding="UTF-8"?><svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">');
this.push('</svg>');
this.push(null);
}
});

await probe(stream);
});
});

0 comments on commit 5aa8410

Please sign in to comment.