Merge pull request #8129 from Snuffleupagus/getInheritedPageProp-undefined

Return `undefined` instead of `Dict.empty` from `Page.getInheritedPageProp` for non-existent properties to prevent possible future bugs
This commit is contained in:
Tim van der Meij 2017-03-04 16:18:24 +01:00 committed by GitHub
commit 4e3e97be8e

View File

@ -119,16 +119,15 @@ var Page = (function PageClosure() {
valueArray.push(value); valueArray.push(value);
} }
if (++loopCount > MAX_LOOP_COUNT) { if (++loopCount > MAX_LOOP_COUNT) {
warn('Page_getInheritedPageProp: maximum loop count exceeded.'); warn('getInheritedPageProp: maximum loop count exceeded for ' + key);
break; return valueArray ? valueArray[0] : undefined;
} }
dict = dict.get('Parent'); dict = dict.get('Parent');
} }
if (!valueArray) { if (!valueArray) {
return Dict.empty; return undefined;
} }
if (valueArray.length === 1 || !isDict(valueArray[0]) || if (valueArray.length === 1 || !isDict(valueArray[0])) {
loopCount > MAX_LOOP_COUNT) {
return valueArray[0]; return valueArray[0];
} }
return Dict.merge(this.xref, valueArray); return Dict.merge(this.xref, valueArray);
@ -142,7 +141,8 @@ var Page = (function PageClosure() {
// For robustness: The spec states that a \Resources entry has to be // For robustness: The spec states that a \Resources entry has to be
// present, but can be empty. Some document omit it still, in this case // present, but can be empty. Some document omit it still, in this case
// we return an empty dictionary. // we return an empty dictionary.
return shadow(this, 'resources', this.getInheritedPageProp('Resources')); return shadow(this, 'resources',
this.getInheritedPageProp('Resources') || Dict.empty);
}, },
get mediaBox() { get mediaBox() {