From 2cdf928fc7b2a0d5cdf4942718d764ccc0b08d9d Mon Sep 17 00:00:00 2001 From: LenAnderson Date: Fri, 26 Jan 2024 18:58:44 +0000 Subject: [PATCH] unescape args before calling callback --- public/scripts/slash-commands.js | 13 +++++++++++++ public/scripts/variables.js | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index 103e33857..b30f322f6 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -1565,6 +1565,19 @@ async function executeSlashCommands(text, unescape = false) { unnamedArg = unnamedArg.replace(/{{pipe}}/i, pipeResult ?? ''); } + unnamedArg = unnamedArg + ?.replace(/\\\|/g, '|') + ?.replace(/\\\{/g, '{') + ?.replace(/\\\}/g, '}') + ; + for (const [key, value] of Object.entries(result.args)) { + result.args[key] = value + .replace(/\\\|/g, '|') + .replace(/\\\{/g, '{') + .replace(/\\\}/g, '}') + ; + } + pipeResult = await result.command.callback(result.args, unnamedArg); if (result.command.interruptsGeneration) { diff --git a/public/scripts/variables.js b/public/scripts/variables.js index a3a8b6f9d..e05adcc86 100644 --- a/public/scripts/variables.js +++ b/public/scripts/variables.js @@ -492,7 +492,7 @@ async function executeSubCommands(command) { command = command.slice(0, -1); } - const unescape = true; + const unescape = false; const result = await executeSlashCommands(command, unescape); if (!result || typeof result !== 'object') {