mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-03 03:17:54 +01:00
#1781 Fix /len and unescape for non-string arguments
This commit is contained in:
parent
37d94a4331
commit
07677584c4
@ -1561,7 +1561,8 @@ async function executeSlashCommands(text, unescape = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof unnamedArg === 'string' && /{{pipe}}/i.test(unnamedArg)) {
|
if (typeof unnamedArg === 'string') {
|
||||||
|
if (/{{pipe}}/i.test(unnamedArg)) {
|
||||||
unnamedArg = unnamedArg.replace(/{{pipe}}/i, pipeResult ?? '');
|
unnamedArg = unnamedArg.replace(/{{pipe}}/i, pipeResult ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1570,13 +1571,17 @@ async function executeSlashCommands(text, unescape = false) {
|
|||||||
?.replace(/\\\{/g, '{')
|
?.replace(/\\\{/g, '{')
|
||||||
?.replace(/\\\}/g, '}')
|
?.replace(/\\\}/g, '}')
|
||||||
;
|
;
|
||||||
|
}
|
||||||
|
|
||||||
for (const [key, value] of Object.entries(result.args)) {
|
for (const [key, value] of Object.entries(result.args)) {
|
||||||
|
if (typeof value === 'string') {
|
||||||
result.args[key] = value
|
result.args[key] = value
|
||||||
.replace(/\\\|/g, '|')
|
.replace(/\\\|/g, '|')
|
||||||
.replace(/\\\{/g, '{')
|
.replace(/\\\{/g, '{')
|
||||||
.replace(/\\\}/g, '}')
|
.replace(/\\\}/g, '}')
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pipeResult = await result.command.callback(result.args, unnamedArg);
|
pipeResult = await result.command.callback(result.args, unnamedArg);
|
||||||
|
|
||||||
|
@ -649,8 +649,20 @@ function lenValuesCallback(value) {
|
|||||||
} catch {
|
} catch {
|
||||||
// could not parse
|
// could not parse
|
||||||
}
|
}
|
||||||
|
if (Array.isArray(parsedValue)) {
|
||||||
return parsedValue.length;
|
return parsedValue.length;
|
||||||
}
|
}
|
||||||
|
switch (typeof parsedValue) {
|
||||||
|
case 'string':
|
||||||
|
return parsedValue.length;
|
||||||
|
case 'object':
|
||||||
|
return Object.keys(parsedValue).length;
|
||||||
|
case 'number':
|
||||||
|
return String(parsedValue).length;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function randValuesCallback(from, to, args) {
|
function randValuesCallback(from, to, args) {
|
||||||
const range = to - from;
|
const range = to - from;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user