mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-02-08 00:21:11 +01:00
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:
parent
a5010f99e7
commit
b5ed988267
@ -68,6 +68,10 @@ class BaseStream {
|
||||
return false;
|
||||
}
|
||||
|
||||
get isImageStream() {
|
||||
return false;
|
||||
}
|
||||
|
||||
get canAsyncDecodeImageFromBuffer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -55,6 +55,10 @@ class CCITTFaxStream extends DecodeStream {
|
||||
this.buffer[this.bufferLength++] = c;
|
||||
}
|
||||
}
|
||||
|
||||
get isImageStream() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export { CCITTFaxStream };
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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)) {
|
||||
|
||||
@ -52,6 +52,10 @@ class Jbig2Stream extends DecodeStream {
|
||||
return true;
|
||||
}
|
||||
|
||||
get isImageStream() {
|
||||
return true;
|
||||
}
|
||||
|
||||
async decodeImage(bytes, _decoderOptions) {
|
||||
if (this.eof) {
|
||||
return this.buffer;
|
||||
|
||||
@ -194,6 +194,10 @@ class JpegStream extends DecodeStream {
|
||||
decoder?.close();
|
||||
}
|
||||
}
|
||||
|
||||
get isImageStream() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export { JpegStream };
|
||||
|
||||
@ -64,6 +64,10 @@ class JpxStream extends DecodeStream {
|
||||
get canAsyncDecodeImageFromBuffer() {
|
||||
return this.stream.isAsync;
|
||||
}
|
||||
|
||||
get isImageStream() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export { JpxStream };
|
||||
|
||||
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -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
BIN
test/pdfs/bomb_giant.pdf
Executable file
Binary file not shown.
@ -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"
|
||||
}
|
||||
]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user