From 5aa84102186773861ecece741997e75f403c39be Mon Sep 17 00:00:00 2001 From: misos1 <30872003+misos1@users.noreply.github.com> Date: Thu, 18 Mar 2021 15:50:52 +0100 Subject: [PATCH] svg: fix "push after EOF" error (#53) Co-authored-by: Michal --- lib/parse_stream/svg.js | 1 + test/test_stream.js | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/parse_stream/svg.js b/lib/parse_stream/svg.js index a62d602..1f092cb 100644 --- a/lib/parse_stream/svg.js +++ b/lib/parse_stream/svg.js @@ -160,6 +160,7 @@ module.exports = function () { var result = parseSvg(str); if (result) { + state = STATE_IGNORE; parser.push(result); parser.push(null); break; diff --git a/test/test_stream.js b/test/test_stream.js index d4b0548..be33fd3 100644 --- a/test/test_stream.js +++ b/test/test_stream.js @@ -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(''); + this.push(''); + this.push(null); + } + }); + + await probe(stream); + }); });