1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 09:38:06 +02:00

Merge pull request #7534 from Snuffleupagus/isName-name-check

Add a parameter to the `isName` function that enables checking not just that something is a `Name`, but also that the actual `name` properties matches
This commit is contained in:
Tim van der Meij 2016-08-17 15:48:42 +02:00 committed by GitHub
commit b4c8814fc9
6 changed files with 23 additions and 27 deletions

View file

@ -94,8 +94,7 @@ var Catalog = (function CatalogClosure() {
var type = stream.dict.get('Type');
var subtype = stream.dict.get('Subtype');
if (isName(type) && isName(subtype) &&
type.name === 'Metadata' && subtype.name === 'XML') {
if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
// XXX: This should examine the charset the XML document defines,
// however since there are currently no real means to decode
// arbitrary charsets, let's just hope that the author of the PDF
@ -304,7 +303,7 @@ var Catalog = (function CatalogClosure() {
assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
var type = labelDict.get('Type');
assert(!type || (isName(type) && type.name === 'PageLabel'),
assert(!type || isName(type, 'PageLabel'),
'Invalid type in PageLabel dictionary.');
var s = labelDict.get('S');
@ -382,7 +381,7 @@ var Catalog = (function CatalogClosure() {
var javaScript = [];
function appendIfJavaScriptDict(jsDict) {
var type = jsDict.get('S');
if (!isName(type) || type.name !== 'JavaScript') {
if (!isName(type, 'JavaScript')) {
return;
}
var js = jsDict.get('JS');
@ -410,11 +409,11 @@ var Catalog = (function CatalogClosure() {
var openactionDict = this.catDict.get('OpenAction');
if (isDict(openactionDict, 'Action')) {
var actionType = openactionDict.get('S');
if (isName(actionType) && actionType.name === 'Named') {
if (isName(actionType, 'Named')) {
// The named Print action is not a part of the PDF 1.7 specification,
// but is supported by many PDF readers/writers (including Adobe's).
var action = openactionDict.get('N');
if (isName(action) && action.name === 'Print') {
if (isName(action, 'Print')) {
javaScript.push('print({});');
}
} else {