Merge pull request #7493 from Snuffleupagus/issue-7492
Catch errors and continue parsing in `parseCMap` (issue 7492)
This commit is contained in:
commit
9228a04061
@ -31,9 +31,11 @@
|
|||||||
|
|
||||||
var Util = sharedUtil.Util;
|
var Util = sharedUtil.Util;
|
||||||
var assert = sharedUtil.assert;
|
var assert = sharedUtil.assert;
|
||||||
|
var warn = sharedUtil.warn;
|
||||||
var error = sharedUtil.error;
|
var error = sharedUtil.error;
|
||||||
var isInt = sharedUtil.isInt;
|
var isInt = sharedUtil.isInt;
|
||||||
var isString = sharedUtil.isString;
|
var isString = sharedUtil.isString;
|
||||||
|
var MissingDataException = sharedUtil.MissingDataException;
|
||||||
var isName = corePrimitives.isName;
|
var isName = corePrimitives.isName;
|
||||||
var isCmd = corePrimitives.isCmd;
|
var isCmd = corePrimitives.isCmd;
|
||||||
var isStream = corePrimitives.isStream;
|
var isStream = corePrimitives.isStream;
|
||||||
@ -881,41 +883,49 @@ var CMapFactory = (function CMapFactoryClosure() {
|
|||||||
var previous;
|
var previous;
|
||||||
var embededUseCMap;
|
var embededUseCMap;
|
||||||
objLoop: while (true) {
|
objLoop: while (true) {
|
||||||
var obj = lexer.getObj();
|
try {
|
||||||
if (isEOF(obj)) {
|
var obj = lexer.getObj();
|
||||||
break;
|
if (isEOF(obj)) {
|
||||||
} else if (isName(obj)) {
|
break;
|
||||||
if (obj.name === 'WMode') {
|
} else if (isName(obj)) {
|
||||||
parseWMode(cMap, lexer);
|
if (obj.name === 'WMode') {
|
||||||
} else if (obj.name === 'CMapName') {
|
parseWMode(cMap, lexer);
|
||||||
parseCMapName(cMap, lexer);
|
} else if (obj.name === 'CMapName') {
|
||||||
|
parseCMapName(cMap, lexer);
|
||||||
|
}
|
||||||
|
previous = obj;
|
||||||
|
} else if (isCmd(obj)) {
|
||||||
|
switch (obj.cmd) {
|
||||||
|
case 'endcmap':
|
||||||
|
break objLoop;
|
||||||
|
case 'usecmap':
|
||||||
|
if (isName(previous)) {
|
||||||
|
embededUseCMap = previous.name;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'begincodespacerange':
|
||||||
|
parseCodespaceRange(cMap, lexer);
|
||||||
|
break;
|
||||||
|
case 'beginbfchar':
|
||||||
|
parseBfChar(cMap, lexer);
|
||||||
|
break;
|
||||||
|
case 'begincidchar':
|
||||||
|
parseCidChar(cMap, lexer);
|
||||||
|
break;
|
||||||
|
case 'beginbfrange':
|
||||||
|
parseBfRange(cMap, lexer);
|
||||||
|
break;
|
||||||
|
case 'begincidrange':
|
||||||
|
parseCidRange(cMap, lexer);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
previous = obj;
|
} catch (ex) {
|
||||||
} else if (isCmd(obj)) {
|
if (ex instanceof MissingDataException) {
|
||||||
switch (obj.cmd) {
|
throw ex;
|
||||||
case 'endcmap':
|
|
||||||
break objLoop;
|
|
||||||
case 'usecmap':
|
|
||||||
if (isName(previous)) {
|
|
||||||
embededUseCMap = previous.name;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'begincodespacerange':
|
|
||||||
parseCodespaceRange(cMap, lexer);
|
|
||||||
break;
|
|
||||||
case 'beginbfchar':
|
|
||||||
parseBfChar(cMap, lexer);
|
|
||||||
break;
|
|
||||||
case 'begincidchar':
|
|
||||||
parseCidChar(cMap, lexer);
|
|
||||||
break;
|
|
||||||
case 'beginbfrange':
|
|
||||||
parseBfRange(cMap, lexer);
|
|
||||||
break;
|
|
||||||
case 'begincidrange':
|
|
||||||
parseCidRange(cMap, lexer);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
warn('Invalid cMap data: ' + ex);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -926,9 +936,8 @@ var CMapFactory = (function CMapFactoryClosure() {
|
|||||||
}
|
}
|
||||||
if (useCMap) {
|
if (useCMap) {
|
||||||
return extendCMap(cMap, builtInCMapParams, useCMap);
|
return extendCMap(cMap, builtInCMapParams, useCMap);
|
||||||
} else {
|
|
||||||
return Promise.resolve(cMap);
|
|
||||||
}
|
}
|
||||||
|
return Promise.resolve(cMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
function extendCMap(cMap, builtInCMapParams, useCMap) {
|
function extendCMap(cMap, builtInCMapParams, useCMap) {
|
||||||
@ -990,8 +999,6 @@ var CMapFactory = (function CMapFactoryClosure() {
|
|||||||
parseCMap(cMap, lexer, builtInCMapParams, null).then(
|
parseCMap(cMap, lexer, builtInCMapParams, null).then(
|
||||||
function (parsedCMap) {
|
function (parsedCMap) {
|
||||||
resolve(parsedCMap);
|
resolve(parsedCMap);
|
||||||
}).catch(function (e) {
|
|
||||||
reject(new Error({ message: 'Invalid CMap data', error: e }));
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
reject(new Error('Unable to get cMap at: ' + url));
|
reject(new Error('Unable to get cMap at: ' + url));
|
||||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -28,6 +28,7 @@
|
|||||||
!issue7200.pdf
|
!issue7200.pdf
|
||||||
!issue7229.pdf
|
!issue7229.pdf
|
||||||
!issue7439.pdf
|
!issue7439.pdf
|
||||||
|
!issue7492.pdf
|
||||||
!filled-background.pdf
|
!filled-background.pdf
|
||||||
!ArabicCIDTrueType.pdf
|
!ArabicCIDTrueType.pdf
|
||||||
!ThuluthFeatures.pdf
|
!ThuluthFeatures.pdf
|
||||||
|
BIN
test/pdfs/issue7492.pdf
Normal file
BIN
test/pdfs/issue7492.pdf
Normal file
Binary file not shown.
@ -1124,6 +1124,20 @@
|
|||||||
"link": false,
|
"link": false,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
},
|
},
|
||||||
|
{ "id": "issue7492-eq",
|
||||||
|
"file": "pdfs/issue7492.pdf",
|
||||||
|
"md5": "7b0b28919c1088a2a5a0aeedbaa4c3ca",
|
||||||
|
"rounds": 1,
|
||||||
|
"link": false,
|
||||||
|
"type": "eq"
|
||||||
|
},
|
||||||
|
{ "id": "issue7492-text",
|
||||||
|
"file": "pdfs/issue7492.pdf",
|
||||||
|
"md5": "7b0b28919c1088a2a5a0aeedbaa4c3ca",
|
||||||
|
"rounds": 1,
|
||||||
|
"link": false,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
{ "id": "ShowText-ShadingPattern",
|
{ "id": "ShowText-ShadingPattern",
|
||||||
"file": "pdfs/ShowText-ShadingPattern.pdf",
|
"file": "pdfs/ShowText-ShadingPattern.pdf",
|
||||||
"md5": "fe683725db037ffe19d390969610a652",
|
"md5": "fe683725db037ffe19d390969610a652",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user