Add validation for filter inject argument

294b15976cf0b855e8b441457ca1e6dea3638630

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +4 -0Showing whitespace changes
public/scripts/slash-commands.js+4 -0
@@ -1962,6 +1962,10 @@ function injectCallback(args, value) {
19621962 const filterFunction = args?.filter instanceof SlashCommandClosure ? closureToFilter(args.filter) : null;
19631963 value = value || '';
19641964
1965+ if (args?.filter && !String(filter ?? '').trim()) {
1966+ throw new Error('Failed to parse the filter argument. Make sure it is a valid non-empty closure.');
1967+ }
1968+
19651969 const prefixedId = `${SCRIPT_PROMPT_KEY}${id}`;
19661970
19671971 if (!chat_metadata.script_injects) {