1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 01:58:06 +02:00

Merge pull request #14180 from Snuffleupagus/bug-1627427

Handle ranges that "overflow" the last byte in `CMap.mapBfRange` (bug 1627427)
This commit is contained in:
Tim van der Meij 2021-10-27 20:06:09 +02:00 committed by GitHub
commit 0e7614df7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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);
}
}