1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 17:48:07 +02:00

Handle ranges that "overflow" the last byte in CMap.mapBfRange (bug 1627427)

This commit is contained in:
Jonas Jenwald 2021-10-24 11:51:57 +02:00
parent 0aaa4e3dbe
commit aa1b78684f
5 changed files with 34 additions and 3 deletions

View file

@ -242,10 +242,17 @@ class CMap {
const lastByte = dstLow.length - 1;
while (low <= high) {
this._map[low++] = dstLow;
// Only the last byte has to be incremented.
// Only the last byte has to be incremented (in the normal case).
const nextCharCode = dstLow.charCodeAt(lastByte) + 1;
if (nextCharCode > 0xff) {
dstLow =
dstLow.substring(0, lastByte - 1) +
String.fromCharCode(dstLow.charCodeAt(lastByte - 1) + 1) +
"\x00";
continue;
}
dstLow =
dstLow.substring(0, lastByte) +
String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
dstLow.substring(0, lastByte) + String.fromCharCode(nextCharCode);
}
}