Skip to content

Add a missing string-check in the _collectJS helper function #14572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/core/core_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import {
stringToPDFString,
warn,
} 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) {
let lookup;
Expand Down Expand Up @@ -329,15 +330,15 @@ function _collectJS(entry, xref, list, parents) {
_collectJS(element, xref, list, parents);
}
} 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");
let code;
if (isStream(js)) {
if (js instanceof BaseStream) {
code = js.getString();
} else {
} else if (typeof js === "string") {
code = js;
}
code = stringToPDFString(code);
code = code && stringToPDFString(code);
if (code) {
list.push(code);
}
Expand Down