mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-03 13:45:49 +02:00
Merge pull request #21522 from spokodev/w32/pdfjs-escapepdfname
Fix escapePDFName producing malformed name escapes for control characters
This commit is contained in:
commit
d5dafc3fb3
@ -376,7 +376,7 @@ function escapePDFName(str) {
|
||||
if (start < i) {
|
||||
buffer.push(str.substring(start, i));
|
||||
}
|
||||
buffer.push(`#${char.toString(16)}`);
|
||||
buffer.push(`#${char.toString(16).padStart(2, "0")}`);
|
||||
start = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -290,6 +290,11 @@ describe("core_utils", function () {
|
||||
"#23#28#29#3c#3e#5b#5d#7b#7d#2f#25"
|
||||
);
|
||||
});
|
||||
|
||||
it("should escape control characters using two hexadecimal digits", function () {
|
||||
expect(escapePDFName("\x00\x09\x0a\x1f")).toEqual("#00#09#0a#1f");
|
||||
expect(escapePDFName("a\tb")).toEqual("a#09b");
|
||||
});
|
||||
});
|
||||
|
||||
describe("escapeString", function () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user