mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-26 18:15:48 +02: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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isImageStream() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
get canAsyncDecodeImageFromBuffer() {
|
get canAsyncDecodeImageFromBuffer() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,6 +55,10 @@ class CCITTFaxStream extends DecodeStream {
|
|||||||
this.buffer[this.bufferLength++] = c;
|
this.buffer[this.bufferLength++] = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isImageStream() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { CCITTFaxStream };
|
export { CCITTFaxStream };
|
||||||
|
|||||||
@ -148,7 +148,7 @@ class DecodeStream extends BaseStream {
|
|||||||
|
|
||||||
class StreamsSequenceStream extends DecodeStream {
|
class StreamsSequenceStream extends DecodeStream {
|
||||||
constructor(streams, onError = null) {
|
constructor(streams, onError = null) {
|
||||||
streams = streams.filter(s => s instanceof BaseStream);
|
streams = streams.filter(s => s instanceof BaseStream && !s.isImageStream);
|
||||||
|
|
||||||
let maybeLength = 0;
|
let maybeLength = 0;
|
||||||
for (const stream of streams) {
|
for (const stream of streams) {
|
||||||
|
|||||||
@ -270,7 +270,7 @@ class Page {
|
|||||||
async getContentStream() {
|
async getContentStream() {
|
||||||
const content = await this.pdfManager.ensure(this, "content");
|
const content = await this.pdfManager.ensure(this, "content");
|
||||||
|
|
||||||
if (content instanceof BaseStream) {
|
if (content instanceof BaseStream && !content.isImageStream) {
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
if (Array.isArray(content)) {
|
if (Array.isArray(content)) {
|
||||||
|
|||||||
@ -52,6 +52,10 @@ class Jbig2Stream extends DecodeStream {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isImageStream() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
async decodeImage(bytes, _decoderOptions) {
|
async decodeImage(bytes, _decoderOptions) {
|
||||||
if (this.eof) {
|
if (this.eof) {
|
||||||
return this.buffer;
|
return this.buffer;
|
||||||
|
|||||||
@ -194,6 +194,10 @@ class JpegStream extends DecodeStream {
|
|||||||
decoder?.close();
|
decoder?.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isImageStream() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { JpegStream };
|
export { JpegStream };
|
||||||
|
|||||||
@ -64,6 +64,10 @@ class JpxStream extends DecodeStream {
|
|||||||
get canAsyncDecodeImageFromBuffer() {
|
get canAsyncDecodeImageFromBuffer() {
|
||||||
return this.stream.isAsync;
|
return this.stream.isAsync;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isImageStream() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { JpxStream };
|
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-harder.pdf
|
||||||
!bitmap-trailing-7fff-stripped.pdf
|
!bitmap-trailing-7fff-stripped.pdf
|
||||||
!bitmap.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,
|
"rounds": 1,
|
||||||
"type": "eq",
|
"type": "eq",
|
||||||
"useWasm": false
|
"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