Browse Source

Add a bit more validation to `Catalog_readPageLabels`, to ensure that the Page Labels are well formed

Jonas Jenwald 9 years ago
parent
commit
0844a72b4d
  1. 16
      src/core/obj.js

16
src/core/obj.js

@ -283,7 +283,6 @@ var Catalog = (function CatalogClosure() { @@ -283,7 +283,6 @@ var Catalog = (function CatalogClosure() {
var pageLabels = new Array(this.numPages);
var style = null;
var prefix = '';
var start = 1;
var numberTree = new NumberTree(obj, this.xref);
var nums = numberTree.getAll();
@ -300,15 +299,16 @@ var Catalog = (function CatalogClosure() { @@ -300,15 +299,16 @@ var Catalog = (function CatalogClosure() {
var s = labelDict.get('S');
assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
style = (s ? s.name : null);
style = s ? s.name : null;
var p = labelDict.get('P') || '';
assert(isString(p), 'Invalid prefix in PageLabel dictionary.');
prefix = stringToPDFString(p);
var p = labelDict.get('P');
assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
prefix = p ? stringToPDFString(p) : '';
start = labelDict.get('St') || 1;
assert(isInt(start), 'Invalid start in PageLabel dictionary.');
currentIndex = start;
var st = labelDict.get('St');
assert(!st || (isInt(st) && st >= 1),
'Invalid start in PageLabel dictionary.');
currentIndex = st || 1;
}
switch (style) {

Loading…
Cancel
Save