Add a missing string-check in the _collectJS
helper function
Unfortunately I don't have a test-case that breaks without this change, however the `stringToPDFString` helper function will fail if anything other than a string is passed to it. The changes in this patch thus make this code more-or-less identical to that found in the `Catalog.{_collectJavaScript, parseDestDictionary}` methods.
This commit is contained in:
parent
d5f048abe0
commit
fd319e94b3
@ -22,7 +22,8 @@ import {
|
|||||||
stringToPDFString,
|
stringToPDFString,
|
||||||
warn,
|
warn,
|
||||||
} from "../shared/util.js";
|
} from "../shared/util.js";
|
||||||
import { Dict, isName, isRef, isStream, RefSet } from "./primitives.js";
|
import { Dict, isName, isRef, RefSet } from "./primitives.js";
|
||||||
|
import { BaseStream } from "./base_stream.js";
|
||||||
|
|
||||||
function getLookupTableFactory(initializer) {
|
function getLookupTableFactory(initializer) {
|
||||||
let lookup;
|
let lookup;
|
||||||
@ -329,15 +330,15 @@ function _collectJS(entry, xref, list, parents) {
|
|||||||
_collectJS(element, xref, list, parents);
|
_collectJS(element, xref, list, parents);
|
||||||
}
|
}
|
||||||
} else if (entry instanceof Dict) {
|
} else if (entry instanceof Dict) {
|
||||||
if (isName(entry.get("S"), "JavaScript") && entry.has("JS")) {
|
if (isName(entry.get("S"), "JavaScript")) {
|
||||||
const js = entry.get("JS");
|
const js = entry.get("JS");
|
||||||
let code;
|
let code;
|
||||||
if (isStream(js)) {
|
if (js instanceof BaseStream) {
|
||||||
code = js.getString();
|
code = js.getString();
|
||||||
} else {
|
} else if (typeof js === "string") {
|
||||||
code = js;
|
code = js;
|
||||||
}
|
}
|
||||||
code = stringToPDFString(code);
|
code = code && stringToPDFString(code);
|
||||||
if (code) {
|
if (code) {
|
||||||
list.push(code);
|
list.push(code);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user