Skip to content

Commit 4db8f0b

Browse files
committed
lock more things behind enable JS setting
1 parent 8691470 commit 4db8f0b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/core/src/fields/button/ButtonActionRunner.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { expectType, openURL } from 'packages/core/src/utils/Utils';
2323
import { parseLiteral } from 'packages/core/src/utils/Literal';
2424

2525
import { type NotePosition } from 'packages/core/src/config/APIConfigs';
26-
import { ErrorLevel, MetaBindParsingError } from 'packages/core/src/utils/errors/MetaBindErrors';
26+
import { ErrorLevel, MetaBindJsError, MetaBindParsingError } from 'packages/core/src/utils/errors/MetaBindErrors';
2727

2828
export class ButtonActionRunner {
2929
plugin: IPlugin;
@@ -276,6 +276,14 @@ export class ButtonActionRunner {
276276
const bindTarget = this.plugin.api.bindTargetParser.fromStringAndValidate(action.bindTarget, filePath);
277277

278278
if (action.evaluate) {
279+
if (!this.plugin.settings.enableJs) {
280+
throw new MetaBindJsError({
281+
errorLevel: ErrorLevel.CRITICAL,
282+
effect: "Can't evaluate expression.",
283+
cause: 'JS evaluation is disabled in the plugin settings.',
284+
});
285+
}
286+
279287
// eslint-disable-next-line @typescript-eslint/no-implied-eval
280288
const func = new Function('x', `return ${action.value};`) as (value: unknown) => unknown;
281289

0 commit comments

Comments
 (0)