Skip to content

Commit

Permalink
Parenthesis in names are not escaped when saving
Browse files Browse the repository at this point in the history
  • Loading branch information
calixteman committed Nov 24, 2020
1 parent d88d47d commit 496d4c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/core/core_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,13 @@ function escapePDFName(str) {
let start = 0;
for (let i = 0, ii = str.length; i < ii; i++) {
const char = str.charCodeAt(i);
if (char < 0x21 || char > 0x7e || char === 0x23) {
if (
char < 0x21 ||
char > 0x7e ||
char === 0x23 /* # */ ||
char === 0x28 /* ( */ ||
char === 0x29 /* ) */
) {
if (start < i) {
buffer.push(str.substring(start, i));
}
Expand Down
1 change: 1 addition & 0 deletions test/unit/core_utils_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ describe("core_utils", function () {
"#fehe#fell#ffo#ff"
);
expect(escapePDFName("#h#e#l#l#o")).toEqual("#23h#23e#23l#23l#23o");
expect(escapePDFName("(h(e(l)l)o)")).toEqual("#28h#28e#28l#29l#29o#29");
});
});
});

0 comments on commit 496d4c0

Please sign in to comment.