mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Prevent lookup errors in PartialEvaluator.hasBlendModes
from breaking all parsing/rendering of a page (issue 11678)
The PDF document in question is *corrupt*, since it contains an XObject with a truncated dictionary and where the stream contents start without a "stream" operator.
This commit is contained in:
parent
7b07b88e71
commit
65e6ea2cb2
3 changed files with 53 additions and 3 deletions
|
@ -61,6 +61,7 @@ import {
|
|||
WinAnsiEncoding,
|
||||
ZapfDingbatsEncoding,
|
||||
} from "./encodings.js";
|
||||
import { getLookupTableFactory, MissingDataException } from "./core_utils.js";
|
||||
import {
|
||||
getNormalizedUnicodes,
|
||||
getUnicodeForGlyph,
|
||||
|
@ -77,7 +78,6 @@ import { bidi } from "./bidi.js";
|
|||
import { ColorSpace } from "./colorspace.js";
|
||||
import { DecodeStream } from "./stream.js";
|
||||
import { getGlyphsUnicode } from "./glyphlist.js";
|
||||
import { getLookupTableFactory } from "./core_utils.js";
|
||||
import { getMetrics } from "./metrics.js";
|
||||
import { isPDFFunction } from "./function.js";
|
||||
import { JpegStream } from "./jpeg_stream.js";
|
||||
|
@ -266,7 +266,27 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
if (processed[graphicState.toString()]) {
|
||||
continue; // The ExtGState has already been processed.
|
||||
}
|
||||
graphicState = xref.fetch(graphicState);
|
||||
try {
|
||||
graphicState = xref.fetch(graphicState);
|
||||
} catch (ex) {
|
||||
if (ex instanceof MissingDataException) {
|
||||
throw ex;
|
||||
}
|
||||
if (this.options.ignoreErrors) {
|
||||
if (graphicState instanceof Ref) {
|
||||
// Avoid parsing a corrupt ExtGState more than once.
|
||||
processed[graphicState.toString()] = true;
|
||||
}
|
||||
// Error(s) in the ExtGState -- sending unsupported feature
|
||||
// notification and allow parsing/rendering to continue.
|
||||
this.handler.send("UnsupportedFeature", {
|
||||
featureId: UNSUPPORTED_FEATURES.unknown,
|
||||
});
|
||||
warn(`hasBlendModes - ignoring ExtGState: "${ex}".`);
|
||||
continue;
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
if (!(graphicState instanceof Dict)) {
|
||||
continue;
|
||||
|
@ -308,7 +328,27 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
// time for badly generated PDF files (fixes issue6961.pdf).
|
||||
continue;
|
||||
}
|
||||
xObject = xref.fetch(xObject);
|
||||
try {
|
||||
xObject = xref.fetch(xObject);
|
||||
} catch (ex) {
|
||||
if (ex instanceof MissingDataException) {
|
||||
throw ex;
|
||||
}
|
||||
if (this.options.ignoreErrors) {
|
||||
if (xObject instanceof Ref) {
|
||||
// Avoid parsing a corrupt XObject more than once.
|
||||
processed[xObject.toString()] = true;
|
||||
}
|
||||
// Error(s) in the XObject -- sending unsupported feature
|
||||
// notification and allow parsing/rendering to continue.
|
||||
this.handler.send("UnsupportedFeature", {
|
||||
featureId: UNSUPPORTED_FEATURES.unknown,
|
||||
});
|
||||
warn(`hasBlendModes - ignoring XObject: "${ex}".`);
|
||||
continue;
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
if (!isStream(xObject)) {
|
||||
continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue