mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 09:38:06 +02:00
When parsing corrupt documents, avoid inserting obviously broken data in the XRef-table (issue 13783)
In cases where even the very *first* attempt at reading from an object will throw, simply ignoring such objects will help improve rendering of *some* corrupt documents. Note that this will lead to more parsing in some cases, but considering that this only applies to *corrupt* documents that shouldn't be a big deal.
This commit is contained in:
parent
51f0a81085
commit
b82c802dff
5 changed files with 51 additions and 10 deletions
|
@ -33,7 +33,11 @@ import {
|
|||
Name,
|
||||
Ref,
|
||||
} from "./primitives.js";
|
||||
import { isWhiteSpace, MissingDataException } from "./core_utils.js";
|
||||
import {
|
||||
isWhiteSpace,
|
||||
MissingDataException,
|
||||
ParserEOFException,
|
||||
} from "./core_utils.js";
|
||||
import { Ascii85Stream } from "./ascii_85_stream.js";
|
||||
import { AsciiHexStream } from "./ascii_hex_stream.js";
|
||||
import { CCITTFaxStream } from "./ccitt_stream.js";
|
||||
|
@ -124,10 +128,10 @@ class Parser {
|
|||
array.push(this.getObj(cipherTransform));
|
||||
}
|
||||
if (isEOF(this.buf1)) {
|
||||
if (!this.recoveryMode) {
|
||||
throw new FormatError("End of file inside array");
|
||||
if (this.recoveryMode) {
|
||||
return array;
|
||||
}
|
||||
return array;
|
||||
throw new ParserEOFException("End of file inside array.");
|
||||
}
|
||||
this.shift();
|
||||
return array;
|
||||
|
@ -148,10 +152,10 @@ class Parser {
|
|||
dict.set(key, this.getObj(cipherTransform));
|
||||
}
|
||||
if (isEOF(this.buf1)) {
|
||||
if (!this.recoveryMode) {
|
||||
throw new FormatError("End of file inside dictionary");
|
||||
if (this.recoveryMode) {
|
||||
return dict;
|
||||
}
|
||||
return dict;
|
||||
throw new ParserEOFException("End of file inside dictionary.");
|
||||
}
|
||||
|
||||
// Stream objects are not allowed inside content streams or
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue