Handle ranges that "overflow" the last byte in CMap.mapBfRange
(bug 1627427)
This commit is contained in:
parent
0aaa4e3dbe
commit
aa1b78684f
@ -242,10 +242,17 @@ class CMap {
|
|||||||
const lastByte = dstLow.length - 1;
|
const lastByte = dstLow.length - 1;
|
||||||
while (low <= high) {
|
while (low <= high) {
|
||||||
this._map[low++] = dstLow;
|
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 =
|
||||||
dstLow.substring(0, lastByte) +
|
dstLow.substring(0, lastByte) + String.fromCharCode(nextCharCode);
|
||||||
String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -338,6 +338,7 @@
|
|||||||
!noembed-jis7.pdf
|
!noembed-jis7.pdf
|
||||||
!issue12504.pdf
|
!issue12504.pdf
|
||||||
!noembed-eucjp.pdf
|
!noembed-eucjp.pdf
|
||||||
|
!bug1627427_reduced.pdf
|
||||||
!noembed-sjis.pdf
|
!noembed-sjis.pdf
|
||||||
!vertical.pdf
|
!vertical.pdf
|
||||||
!issue13343.pdf
|
!issue13343.pdf
|
||||||
|
BIN
test/pdfs/bug1627427_reduced.pdf
Normal file
BIN
test/pdfs/bug1627427_reduced.pdf
Normal file
Binary file not shown.
@ -3022,6 +3022,13 @@
|
|||||||
"rounds": 1,
|
"rounds": 1,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
},
|
},
|
||||||
|
{ "id": "bug1627427",
|
||||||
|
"file": "pdfs/bug1627427_reduced.pdf",
|
||||||
|
"md5": "3ff75fcf455af49803f0f04eb071bdc3",
|
||||||
|
"link": false,
|
||||||
|
"rounds": 1,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
{ "id": "issue8586",
|
{ "id": "issue8586",
|
||||||
"file": "pdfs/issue8586.pdf",
|
"file": "pdfs/issue8586.pdf",
|
||||||
"md5": "16b5230364017d3b0d2d65978eb35816",
|
"md5": "16b5230364017d3b0d2d65978eb35816",
|
||||||
|
@ -1757,6 +1757,22 @@ sources, for full support with Dvips.`)
|
|||||||
await loadingTask.destroy();
|
await loadingTask.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("gets text content, with beginbfrange operator handled correctly (bug 1627427)", async function () {
|
||||||
|
const loadingTask = getDocument(
|
||||||
|
buildGetDocumentParams("bug1627427_reduced.pdf")
|
||||||
|
);
|
||||||
|
const pdfDoc = await loadingTask.promise;
|
||||||
|
const pdfPage = await pdfDoc.getPage(1);
|
||||||
|
const { items } = await pdfPage.getTextContent();
|
||||||
|
const text = mergeText(items);
|
||||||
|
|
||||||
|
expect(text).toEqual(
|
||||||
|
"침하게 흐린 품이 눈이 올 듯하더니 눈은 아니 오고 얼다가 만 비가 추"
|
||||||
|
);
|
||||||
|
|
||||||
|
await loadingTask.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
it("gets empty structure tree", async function () {
|
it("gets empty structure tree", async function () {
|
||||||
const tree = await page.getStructTree();
|
const tree = await page.getStructTree();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user