Skip to content

Commit d38781d

Browse files
committed
Merge pull request mozilla#1992 from brendandahl/indexedcs-data-clone
Stop streams from being sent from worker for indexed color spaces.
2 parents c9c5ae3 + fd416d3 commit d38781d

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/colorspace.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ var ColorSpace = (function ColorSpaceClosure() {
139139
var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
140140
var hiVal = cs[2] + 1;
141141
var lookup = xref.fetchIfRef(cs[3]);
142+
if (isStream(lookup)) {
143+
lookup = lookup.getBytes();
144+
}
142145
return ['IndexedCS', baseIndexedCS, hiVal, lookup];
143146
case 'Separation':
144147
case 'DeviceN':
@@ -260,14 +263,18 @@ var IndexedCS = (function IndexedCSClosure() {
260263

261264
var baseNumComps = base.numComps;
262265
var length = baseNumComps * highVal;
263-
var lookupArray = new Uint8Array(length);
266+
var lookupArray;
264267

265268
if (isStream(lookup)) {
269+
lookupArray = new Uint8Array(length);
266270
var bytes = lookup.getBytes(length);
267271
lookupArray.set(bytes);
268272
} else if (isString(lookup)) {
273+
lookupArray = new Uint8Array(length);
269274
for (var i = 0; i < length; ++i)
270275
lookupArray[i] = lookup.charCodeAt(i);
276+
} else if (lookup instanceof Uint8Array) {
277+
lookupArray = lookup;
271278
} else {
272279
error('Unrecognized lookup table: ' + lookup);
273280
}

test/pdfs/issue1985.pdf

9.65 KB
Binary file not shown.

test/test_manifest.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,5 +658,11 @@
658658
"pageLimit": 1,
659659
"link": true,
660660
"type": "load"
661+
},
662+
{ "id": "issue1985",
663+
"file": "pdfs/issue1985.pdf",
664+
"md5": "2ac7c68e26a8ef797aead15e4875cc6d",
665+
"rounds": 1,
666+
"type": "load"
661667
}
662668
]

0 commit comments

Comments
 (0)