PDF names need to be escaped when saving

This commit is contained in:
Calixte Denizet 2020-09-09 18:39:14 +02:00
parent f9d56320f5
commit dc4eb71ff1
4 changed files with 56 additions and 2 deletions

View file

@ -15,6 +15,7 @@
import { Dict, Ref } from "../../src/core/primitives.js";
import {
escapePDFName,
getInheritableProperty,
isWhiteSpace,
log2,
@ -226,4 +227,16 @@ describe("core_utils", function () {
]);
});
});
describe("escapePDFName", function () {
it("should escape PDF name", function () {
expect(escapePDFName("hello")).toEqual("hello");
expect(escapePDFName("\xfehello")).toEqual("#fehello");
expect(escapePDFName("he\xfell\xffo")).toEqual("he#fell#ffo");
expect(escapePDFName("\xfehe\xfell\xffo\xff")).toEqual(
"#fehe#fell#ffo#ff"
);
expect(escapePDFName("#h#e#l#l#o")).toEqual("#23h#23e#23l#23l#23o");
});
});
});