Don't use contents stream which have an image format

The original bug has been filled in mupdf bug tracker:
https://bugs.ghostscript.com/show_bug.cgi?id=709033

The attached pdf can be open in Chrome but not in Acrobat.
This commit is contained in:
Calixte Denizet 2026-01-13 18:39:08 +01:00
parent a5010f99e7
commit b5ed988267
No known key found for this signature in database
GPG Key ID: 0C5442631EE0691F
10 changed files with 30 additions and 2 deletions

View File

@ -68,6 +68,10 @@ class BaseStream {
return false;
}
get isImageStream() {
return false;
}
get canAsyncDecodeImageFromBuffer() {
return false;
}

View File

@ -55,6 +55,10 @@ class CCITTFaxStream extends DecodeStream {
this.buffer[this.bufferLength++] = c;
}
}
get isImageStream() {
return true;
}
}
export { CCITTFaxStream };

View File

@ -148,7 +148,7 @@ class DecodeStream extends BaseStream {
class StreamsSequenceStream extends DecodeStream {
constructor(streams, onError = null) {
streams = streams.filter(s => s instanceof BaseStream);
streams = streams.filter(s => s instanceof BaseStream && !s.isImageStream);
let maybeLength = 0;
for (const stream of streams) {

View File

@ -270,7 +270,7 @@ class Page {
async getContentStream() {
const content = await this.pdfManager.ensure(this, "content");
if (content instanceof BaseStream) {
if (content instanceof BaseStream && !content.isImageStream) {
return content;
}
if (Array.isArray(content)) {

View File

@ -52,6 +52,10 @@ class Jbig2Stream extends DecodeStream {
return true;
}
get isImageStream() {
return true;
}
async decodeImage(bytes, _decoderOptions) {
if (this.eof) {
return this.buffer;

View File

@ -194,6 +194,10 @@ class JpegStream extends DecodeStream {
decoder?.close();
}
}
get isImageStream() {
return true;
}
}
export { JpegStream };

View File

@ -64,6 +64,10 @@ class JpxStream extends DecodeStream {
get canAsyncDecodeImageFromBuffer() {
return this.stream.isAsync;
}
get isImageStream() {
return true;
}
}
export { JpxStream };

View File

@ -866,3 +866,4 @@
!bitmap-trailing-7fff-stripped-harder.pdf
!bitmap-trailing-7fff-stripped.pdf
!bitmap.pdf
!bomb_giant.pdf

BIN
test/pdfs/bomb_giant.pdf Executable file

Binary file not shown.

View File

@ -13922,5 +13922,12 @@
"rounds": 1,
"type": "eq",
"useWasm": false
},
{
"id": "bomb_giant_contents_image_stream",
"file": "pdfs/bomb_giant.pdf",
"md5": "e515a9abb11ab74332e57e371bfae61e",
"rounds": 1,
"type": "eq"
}
]