Skip to content

Commit

Permalink
馃悰 (setVariable) Avoid octal number evalution
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Jan 29, 2024
1 parent 5f0b369 commit ef05b71
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ const evaluateSetVariableExpression =
const isSingleVariable =
str.startsWith('{{') && str.endsWith('}}') && str.split('{{').length === 2
if (isSingleVariable) return parseVariables(variables)(str)
// To avoid octal number evaluation
if (!isNaN(str as unknown as number) && /0[^.].+/.test(str)) return str
const evaluating = parseVariables(variables, { fieldToParse: 'id' })(
str.includes('return ') ? str : `return ${str}`
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ export const executeSetVariable = async ({
args,
}: ScriptToExecute): Promise<{ replyToSend: string | undefined }> => {
try {
// To avoid octal number evaluation
if (!isNaN(content as unknown as number) && /0[^.].+/.test(content))
return {
replyToSend: content,
}
const func = AsyncFunction(
...args.map((arg) => arg.id),
content.includes('return ') ? content : `return ${content}`
Expand Down

0 comments on commit ef05b71

Please sign in to comment.