From 48a18585f299dbad1e80b0e761bfbdcbbcf7958e Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 29 Oct 2024 08:52:14 +0100 Subject: [PATCH] Allow `StreamsSequenceStream` to skip sub-streams that are not actual Streams (issue 18973) This extends PR 13796 to also handle the case where sub-streams contain invalid data, i.e. anything that isn't a Stream, however please note that in these cases there's no guarantee that we'll render the page "correctly". Note that Adobe Reader, i.e. the PDF reference implementation, cannot render the last page of the referenced PDF document. --- src/core/decode_stream.js | 2 ++ test/pdfs/issue18973.pdf.link | 1 + test/test_manifest.json | 9 +++++++++ 3 files changed, 12 insertions(+) create mode 100644 test/pdfs/issue18973.pdf.link diff --git a/src/core/decode_stream.js b/src/core/decode_stream.js index 1d963b4e4502e..dd93121fbb839 100644 --- a/src/core/decode_stream.js +++ b/src/core/decode_stream.js @@ -132,6 +132,8 @@ class DecodeStream extends BaseStream { class StreamsSequenceStream extends DecodeStream { constructor(streams, onError = null) { + streams = streams.filter(s => s instanceof BaseStream); + let maybeLength = 0; for (const stream of streams) { maybeLength += diff --git a/test/pdfs/issue18973.pdf.link b/test/pdfs/issue18973.pdf.link new file mode 100644 index 0000000000000..cb4580ff37831 --- /dev/null +++ b/test/pdfs/issue18973.pdf.link @@ -0,0 +1 @@ +https://github.com/user-attachments/files/17550758/doc1520828609.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index da0e82f7f77c3..7cfd0356ee2fc 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -2057,6 +2057,15 @@ "firstPage": 3, "type": "eq" }, + { + "id": "issue18973", + "file": "pdfs/issue18973.pdf", + "md5": "b9bbd312269862bf39bb2a31023a9d02", + "link": true, + "rounds": 1, + "firstPage": 45, + "type": "eq" + }, { "id": "issue9262", "file": "pdfs/issue9262_reduced.pdf",