From 78bdda890f6490e283ad8c4a7cd5ff06a37cc605 Mon Sep 17 00:00:00 2001 From: gdh1995 Date: Fri, 16 Aug 2024 02:13:38 +0800 Subject: [PATCH] fix escaping --- lib/simple_eval.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/simple_eval.ts b/lib/simple_eval.ts index 7a9d5a59e..fde97d653 100644 --- a/lib/simple_eval.ts +++ b/lib/simple_eval.ts @@ -1128,8 +1128,8 @@ const ToString = (op: Op, allowed: number): string => { && typeof i.v.v === "object" && i.v.v && i.v.v !== kFakeValue && i.v.v.c < 4 ? i.v.v as Extract : null return literal ? (literal.c & 1 ? "`" : "}") + JSON.stringify(literal.v).slice(1, -1) - .replace(> /`|\\["tn]/g, s => s === "`" ? "\\`" : s[1] === '"' ? '"' - : s[1] === "t" ? "\t" : "\n") + (literal.c & 2 ? "`" : "${") + .replace(> /`|\\[\\"tn]/g, s => s === "`" ? "\\`" : s[1] === '"' ? '"' + : s[1] < "a" ? s : s[1] === "t" ? "\t" : "\n") + (literal.c & 2 ? "`" : "${") : ToString(i, allowed && (allowed | (1 << O.binary) | (1 << O.unary) | (1 << O.access) | (1 << O.token))) }).join("") : op.v.o.v + (op.v.o.v >= "a" && op.v.o.v < "zz" ? " " : "") + (ToString(op.v.x, allowed) || kUnknown)