mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Merge pull request #14268 from calixteman/outline
Remove non-displayable chars from outline title (#14267)
This commit is contained in:
commit
85c6dd59ce
6 changed files with 38 additions and 3 deletions
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
|
@ -486,3 +486,4 @@
|
|||
!pr12828.pdf
|
||||
!secHandler.pdf
|
||||
!rc_annotation.pdf
|
||||
!issue14267.pdf
|
BIN
test/pdfs/issue14267.pdf
Normal file
BIN
test/pdfs/issue14267.pdf
Normal file
Binary file not shown.
|
@ -1102,6 +1102,19 @@ describe("api", function () {
|
|||
await loadingTask.destroy();
|
||||
});
|
||||
|
||||
it("gets outline with non-displayable chars", async function () {
|
||||
const loadingTask = getDocument(buildGetDocumentParams("issue14267.pdf"));
|
||||
const pdfDoc = await loadingTask.promise;
|
||||
const outline = await pdfDoc.getOutline();
|
||||
expect(Array.isArray(outline)).toEqual(true);
|
||||
expect(outline.length).toEqual(1);
|
||||
|
||||
const outlineItem = outline[0];
|
||||
expect(outlineItem.title).toEqual("hello\x11world");
|
||||
|
||||
await loadingTask.destroy();
|
||||
});
|
||||
|
||||
it("gets non-existent permissions", async function () {
|
||||
const permissions = await pdfDocument.getPermissions();
|
||||
expect(permissions).toEqual(null);
|
||||
|
|
|
@ -185,6 +185,18 @@ describe("util", function () {
|
|||
const str = "string\x00With\x00Null\x00Chars";
|
||||
expect(removeNullCharacters(str)).toEqual("stringWithNullChars");
|
||||
});
|
||||
|
||||
it("should modify string with non-displayable characters", function () {
|
||||
const str = Array.from(Array(32).keys())
|
||||
.map(x => String.fromCharCode(x) + "a")
|
||||
.join("");
|
||||
// \x00 is replaced by an empty string.
|
||||
const expected =
|
||||
"a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a";
|
||||
expect(removeNullCharacters(str, /* replaceInvisible */ true)).toEqual(
|
||||
expected
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("ReadableStream", function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue