1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 01:58:06 +02:00

Prevent an infinite loop in XRef_fetchUncompressed for encrypted PDF files with indirect objects in the /Encrypt dictionary (issue 7665)

This commit is contained in:
Jonas Jenwald 2016-09-23 14:10:27 +02:00
parent 6c263c1994
commit 3e77cf6b32
3 changed files with 33 additions and 16 deletions

View file

@ -73,6 +73,7 @@ var Dict = (function DictClosure() {
this.map = Object.create(null);
this.xref = xref;
this.objId = null;
this.suppressEncryption = false;
this.__nonSerializable__ = nonSerializable; // disable cloning of the Dict
}
@ -84,40 +85,40 @@ var Dict = (function DictClosure() {
// automatically dereferences Ref objects
get: function Dict_get(key1, key2, key3) {
var value;
var xref = this.xref;
var xref = this.xref, suppressEncryption = this.suppressEncryption;
if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map ||
typeof key2 === 'undefined') {
return xref ? xref.fetchIfRef(value) : value;
return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
}
if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map ||
typeof key3 === 'undefined') {
return xref ? xref.fetchIfRef(value) : value;
return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
}
value = this.map[key3] || null;
return xref ? xref.fetchIfRef(value) : value;
return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
},
// Same as get(), but returns a promise and uses fetchIfRefAsync().
getAsync: function Dict_getAsync(key1, key2, key3) {
var value;
var xref = this.xref;
var xref = this.xref, suppressEncryption = this.suppressEncryption;
if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map ||
typeof key2 === 'undefined') {
if (xref) {
return xref.fetchIfRefAsync(value);
return xref.fetchIfRefAsync(value, suppressEncryption);
}
return Promise.resolve(value);
}
if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map ||
typeof key3 === 'undefined') {
if (xref) {
return xref.fetchIfRefAsync(value);
return xref.fetchIfRefAsync(value, suppressEncryption);
}
return Promise.resolve(value);
}
value = this.map[key3] || null;
if (xref) {
return xref.fetchIfRefAsync(value);
return xref.fetchIfRefAsync(value, suppressEncryption);
}
return Promise.resolve(value);
},
@ -125,7 +126,7 @@ var Dict = (function DictClosure() {
// Same as get(), but dereferences all elements if the result is an Array.
getArray: function Dict_getArray(key1, key2, key3) {
var value = this.get(key1, key2, key3);
var xref = this.xref;
var xref = this.xref, suppressEncryption = this.suppressEncryption;
if (!isArray(value) || !xref) {
return value;
}
@ -134,7 +135,7 @@ var Dict = (function DictClosure() {
if (!isRef(value[i])) {
continue;
}
value[i] = xref.fetch(value[i]);
value[i] = xref.fetch(value[i], suppressEncryption);
}
return value;
},