Add validation for filter inject argument

294b15976cf0b855e8b441457ca1e6dea3638630

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

1 files changed, +4 -0Ignore whitespace
public/scripts/slash-commands.js+4 -0
@@ -1962,6 +1962,10 @@ function injectCallback(args, value) {
1962 const filterFunction = args?.filter instanceof SlashCommandClosure ? closureToFilter(args.filter) : null;1962 const filterFunction = args?.filter instanceof SlashCommandClosure ? closureToFilter(args.filter) : null;
1963 value = value || '';1963 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
1965 const prefixedId = `${SCRIPT_PROMPT_KEY}${id}`;1969 const prefixedId = `${SCRIPT_PROMPT_KEY}${id}`;
19661970
1967 if (!chat_metadata.script_injects) {1971 if (!chat_metadata.script_injects) {