Do not allow empty or undefined variable names. Closes #3204
| @@ -516,7 +516,11 @@ export function evaluateMacros(content, env, postProcessFn) { | ||
| 516 | 516 | break; |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - content = content.replace(macro.regex, (...args) => postProcessFn(macro.replace(...args))); | |
| 519 | + try { | |
| 520 | + content = content.replace(macro.regex, (...args) => postProcessFn(macro.replace(...args))); | |
| 521 | + } catch (e) { | |
| 522 | + console.warn(`Macro content can't be replaced: ${macro.regex} in ${content}`, e); | |
| 523 | + } | |
| 520 | 524 | } |
| 521 | 525 | |
| 522 | 526 | return content; |
| @@ -46,6 +46,10 @@ function getLocalVariable(name, args = {}) { | ||
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | function setLocalVariable(name, value, args = {}) { |
| 49 | + if (!name) { | |
| 50 | + throw new Error('Variable name cannot be empty or undefined.'); | |
| 51 | + } | |
| 52 | + | |
| 49 | 53 | if (!chat_metadata.variables) { |
| 50 | 54 | chat_metadata.variables = {}; |
| 51 | 55 | } |