Merge pull request #15170 from calixteman/js_rm_null

[JS] Embedded JS scripts can have some null chars
This commit is contained in:
Jonas Jenwald 2022-07-15 17:11:29 +02:00 committed by GitHub
commit de7d1d2167
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -982,7 +982,8 @@ class Catalog {
if (javaScript === null) { if (javaScript === null) {
javaScript = new Map(); javaScript = new Map();
} }
javaScript.set(name, stringToPDFString(js)); js = stringToPDFString(js).replace(/\u0000/g, "");
javaScript.set(name, js);
} }
if (obj instanceof Dict && obj.has("JavaScript")) { if (obj instanceof Dict && obj.has("JavaScript")) {

View File

@ -339,7 +339,7 @@ function _collectJS(entry, xref, list, parents) {
} else if (typeof js === "string") { } else if (typeof js === "string") {
code = js; code = js;
} }
code = code && stringToPDFString(code); code = code && stringToPDFString(code).replace(/\u0000/g, "");
if (code) { if (code) {
list.push(code); list.push(code);
} }