Add validation for filter inject argument

This commit is contained in:
Cohee
2024-12-13 01:20:43 +02:00
parent d1932f4cb5
commit 294b15976c

View File

@ -1962,6 +1962,10 @@ function injectCallback(args, value) {
const filterFunction = args?.filter instanceof SlashCommandClosure ? closureToFilter(args.filter) : null;
value = value || '';
if (args?.filter && !String(filter ?? '').trim()) {
throw new Error('Failed to parse the filter argument. Make sure it is a valid non-empty closure.');
}
const prefixedId = `${SCRIPT_PROMPT_KEY}${id}`;
if (!chat_metadata.script_injects) {