mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 09:38:06 +02:00
Add a recoveryMode
that suppresses errors from the Parser
, and utilize it when searching for the main trailer in XRef_indexObjects
(bug 1250079)
Instead of having `Parser_getObj` fail unconditionally for the referenced PDF file, this patch attempts to let searching for the main trailer continue even if there are errors. Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1250079.
This commit is contained in:
parent
94089960c0
commit
544d29f5cb
5 changed files with 22 additions and 5 deletions
|
@ -66,10 +66,11 @@ function isEOF(v) {
|
|||
var MAX_LENGTH_TO_CACHE = 1000;
|
||||
|
||||
var Parser = (function ParserClosure() {
|
||||
function Parser(lexer, allowStreams, xref) {
|
||||
function Parser(lexer, allowStreams, xref, recoveryMode) {
|
||||
this.lexer = lexer;
|
||||
this.allowStreams = allowStreams;
|
||||
this.xref = xref;
|
||||
this.recoveryMode = recoveryMode || false;
|
||||
this.imageCache = Object.create(null);
|
||||
this.refill();
|
||||
}
|
||||
|
@ -115,7 +116,10 @@ var Parser = (function ParserClosure() {
|
|||
array.push(this.getObj(cipherTransform));
|
||||
}
|
||||
if (isEOF(this.buf1)) {
|
||||
error('End of file inside array');
|
||||
if (!this.recoveryMode) {
|
||||
error('End of file inside array');
|
||||
}
|
||||
return array;
|
||||
}
|
||||
this.shift();
|
||||
return array;
|
||||
|
@ -136,7 +140,10 @@ var Parser = (function ParserClosure() {
|
|||
dict.set(key, this.getObj(cipherTransform));
|
||||
}
|
||||
if (isEOF(this.buf1)) {
|
||||
error('End of file inside dictionary');
|
||||
if (!this.recoveryMode) {
|
||||
error('End of file inside dictionary');
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
|
||||
// Stream objects are not allowed inside content streams or
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue