Skip to content

Commit f40ab1a

Browse files
Merge pull request #20570 from calixteman/no_contents_image_stream
Don't use contents stream which have an image format
2 parents a5010f9 + b5ed988 commit f40ab1a

10 files changed

Lines changed: 30 additions & 2 deletions

File tree

src/core/base_stream.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ class BaseStream {
6868
return false;
6969
}
7070

71+
get isImageStream() {
72+
return false;
73+
}
74+
7175
get canAsyncDecodeImageFromBuffer() {
7276
return false;
7377
}

src/core/ccitt_stream.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ class CCITTFaxStream extends DecodeStream {
5555
this.buffer[this.bufferLength++] = c;
5656
}
5757
}
58+
59+
get isImageStream() {
60+
return true;
61+
}
5862
}
5963

6064
export { CCITTFaxStream };

src/core/decode_stream.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class DecodeStream extends BaseStream {
148148

149149
class StreamsSequenceStream extends DecodeStream {
150150
constructor(streams, onError = null) {
151-
streams = streams.filter(s => s instanceof BaseStream);
151+
streams = streams.filter(s => s instanceof BaseStream && !s.isImageStream);
152152

153153
let maybeLength = 0;
154154
for (const stream of streams) {

src/core/document.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class Page {
270270
async getContentStream() {
271271
const content = await this.pdfManager.ensure(this, "content");
272272

273-
if (content instanceof BaseStream) {
273+
if (content instanceof BaseStream && !content.isImageStream) {
274274
return content;
275275
}
276276
if (Array.isArray(content)) {

src/core/jbig2_stream.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ class Jbig2Stream extends DecodeStream {
5252
return true;
5353
}
5454

55+
get isImageStream() {
56+
return true;
57+
}
58+
5559
async decodeImage(bytes, _decoderOptions) {
5660
if (this.eof) {
5761
return this.buffer;

src/core/jpeg_stream.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ class JpegStream extends DecodeStream {
194194
decoder?.close();
195195
}
196196
}
197+
198+
get isImageStream() {
199+
return true;
200+
}
197201
}
198202

199203
export { JpegStream };

src/core/jpx_stream.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ class JpxStream extends DecodeStream {
6464
get canAsyncDecodeImageFromBuffer() {
6565
return this.stream.isAsync;
6666
}
67+
68+
get isImageStream() {
69+
return true;
70+
}
6771
}
6872

6973
export { JpxStream };

test/pdfs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,3 +866,4 @@
866866
!bitmap-trailing-7fff-stripped-harder.pdf
867867
!bitmap-trailing-7fff-stripped.pdf
868868
!bitmap.pdf
869+
!bomb_giant.pdf

test/pdfs/bomb_giant.pdf

120 KB
Binary file not shown.

test/test_manifest.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13922,5 +13922,12 @@
1392213922
"rounds": 1,
1392313923
"type": "eq",
1392413924
"useWasm": false
13925+
},
13926+
{
13927+
"id": "bomb_giant_contents_image_stream",
13928+
"file": "pdfs/bomb_giant.pdf",
13929+
"md5": "e515a9abb11ab74332e57e371bfae61e",
13930+
"rounds": 1,
13931+
"type": "eq"
1392513932
}
1392613933
]

0 commit comments

Comments
 (0)