Avoid hanging the worker-thread for CMap data with ridiculously large ranges (issue 11922)
This patch was inspired by ad2b64f124/xpdf/CharCodeToUnicode.cc (L480-L484)
This commit is contained in:
parent
4a3a24b002
commit
56ebf01ae0
@ -198,6 +198,10 @@ var BUILT_IN_CMAPS = [
|
||||
"WP-Symbol",
|
||||
];
|
||||
|
||||
// Heuristic to avoid hanging the worker-thread for CMap data with ridiculously
|
||||
// large ranges, such as e.g. 0xFFFFFFFF (fixes issue11922_reduced.pdf).
|
||||
const MAX_MAP_RANGE = 2 ** 24 - 1; // = 0xFFFFFF
|
||||
|
||||
// CMap, not to be confused with TrueType's cmap.
|
||||
class CMap {
|
||||
constructor(builtInCMap = false) {
|
||||
@ -223,12 +227,18 @@ class CMap {
|
||||
}
|
||||
|
||||
mapCidRange(low, high, dstLow) {
|
||||
if (high - low > MAX_MAP_RANGE) {
|
||||
throw new Error("mapCidRange - ignoring data above MAX_MAP_RANGE.");
|
||||
}
|
||||
while (low <= high) {
|
||||
this._map[low++] = dstLow++;
|
||||
}
|
||||
}
|
||||
|
||||
mapBfRange(low, high, dstLow) {
|
||||
if (high - low > MAX_MAP_RANGE) {
|
||||
throw new Error("mapBfRange - ignoring data above MAX_MAP_RANGE.");
|
||||
}
|
||||
var lastByte = dstLow.length - 1;
|
||||
while (low <= high) {
|
||||
this._map[low++] = dstLow;
|
||||
@ -240,6 +250,9 @@ class CMap {
|
||||
}
|
||||
|
||||
mapBfRangeToArray(low, high, array) {
|
||||
if (high - low > MAX_MAP_RANGE) {
|
||||
throw new Error("mapBfRangeToArray - ignoring data above MAX_MAP_RANGE.");
|
||||
}
|
||||
const ii = array.length;
|
||||
let i = 0;
|
||||
while (low <= high && i < ii) {
|
||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -50,6 +50,7 @@
|
||||
!issue7665.pdf
|
||||
!issue7696.pdf
|
||||
!issue7835.pdf
|
||||
!issue11922_reduced.pdf
|
||||
!issue7855.pdf
|
||||
!issue7872.pdf
|
||||
!issue7901.pdf
|
||||
|
10472
test/pdfs/issue11922_reduced.pdf
Normal file
10472
test/pdfs/issue11922_reduced.pdf
Normal file
File diff suppressed because one or more lines are too long
@ -726,6 +726,12 @@
|
||||
"annotations": true,
|
||||
"about": "Annotation with Rect array containing indirect objects."
|
||||
},
|
||||
{ "id": "issue11922",
|
||||
"file": "pdfs/issue11922_reduced.pdf",
|
||||
"md5": "711bb4b4bf92d967644b4f88d11a93db",
|
||||
"rounds": 1,
|
||||
"type": "load"
|
||||
},
|
||||
{ "id": "file_url_link",
|
||||
"file": "pdfs/file_url_link.pdf",
|
||||
"md5": "b0253c96c38d43bc49259bbf36db938a",
|
||||
|
Loading…
Reference in New Issue
Block a user