Ensure that we resolve indirect objects in Filter
and DecodeParms
arrays in parser.js
I've not actually, thus far, come across a PDF file that this patch fixes. However, given the string of recent patches that has fixed issues with indirect objects in arrays, I think that it makes sense to proactively avoid any issues in this code.
This commit is contained in:
parent
aaec490847
commit
b4ac6bd2f6
@ -400,8 +400,11 @@ var Parser = (function ParserClosure() {
|
|||||||
var filter = dict.get('Filter', 'F'), filterName;
|
var filter = dict.get('Filter', 'F'), filterName;
|
||||||
if (isName(filter)) {
|
if (isName(filter)) {
|
||||||
filterName = filter.name;
|
filterName = filter.name;
|
||||||
} else if (isArray(filter) && isName(filter[0])) {
|
} else if (isArray(filter)) {
|
||||||
filterName = filter[0].name;
|
var filterZero = this.xref.fetchIfRef(filter[0]);
|
||||||
|
if (isName(filterZero)) {
|
||||||
|
filterName = filterZero.name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse image stream.
|
// Parse image stream.
|
||||||
@ -540,7 +543,7 @@ var Parser = (function ParserClosure() {
|
|||||||
var params = dict.get('DecodeParms', 'DP');
|
var params = dict.get('DecodeParms', 'DP');
|
||||||
if (isName(filter)) {
|
if (isName(filter)) {
|
||||||
if (isArray(params)) {
|
if (isArray(params)) {
|
||||||
params = params[0];
|
params = this.xref.fetchIfRef(params[0]);
|
||||||
}
|
}
|
||||||
return this.makeFilter(stream, filter.name, length, params);
|
return this.makeFilter(stream, filter.name, length, params);
|
||||||
}
|
}
|
||||||
@ -550,14 +553,14 @@ var Parser = (function ParserClosure() {
|
|||||||
var filterArray = filter;
|
var filterArray = filter;
|
||||||
var paramsArray = params;
|
var paramsArray = params;
|
||||||
for (var i = 0, ii = filterArray.length; i < ii; ++i) {
|
for (var i = 0, ii = filterArray.length; i < ii; ++i) {
|
||||||
filter = filterArray[i];
|
filter = this.xref.fetchIfRef(filterArray[i]);
|
||||||
if (!isName(filter)) {
|
if (!isName(filter)) {
|
||||||
error('Bad filter name: ' + filter);
|
error('Bad filter name: ' + filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
params = null;
|
params = null;
|
||||||
if (isArray(paramsArray) && (i in paramsArray)) {
|
if (isArray(paramsArray) && (i in paramsArray)) {
|
||||||
params = paramsArray[i];
|
params = this.xref.fetchIfRef(paramsArray[i]);
|
||||||
}
|
}
|
||||||
stream = this.makeFilter(stream, filter.name, maybeLength, params);
|
stream = this.makeFilter(stream, filter.name, maybeLength, params);
|
||||||
// after the first stream the length variable is invalid
|
// after the first stream the length variable is invalid
|
||||||
@ -575,9 +578,6 @@ var Parser = (function ParserClosure() {
|
|||||||
return new NullStream(stream);
|
return new NullStream(stream);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (params && this.xref) {
|
|
||||||
params = this.xref.fetchIfRef(params);
|
|
||||||
}
|
|
||||||
var xrefStreamStats = this.xref.stats.streamTypes;
|
var xrefStreamStats = this.xref.stats.streamTypes;
|
||||||
if (name === 'FlateDecode' || name === 'Fl') {
|
if (name === 'FlateDecode' || name === 'Fl') {
|
||||||
xrefStreamStats[StreamType.FLATE] = true;
|
xrefStreamStats[StreamType.FLATE] = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user