Skip to content

Commit

Permalink
fix escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
gdh1995 committed Aug 15, 2024
1 parent 401d005 commit 78bdda8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/simple_eval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ComplexLiteral, { c: 0 | 1 | 2 | 3 }> : null
return literal ? (literal.c & 1 ? "`" : "}") + JSON.stringify(literal.v).slice(1, -1)
.replace(<RegExpG & RegExpSearchable<0>> /`|\\["tn]/g, s => s === "`" ? "\\`" : s[1] === '"' ? '"'
: s[1] === "t" ? "\t" : "\n") + (literal.c & 2 ? "`" : "${")
.replace(<RegExpG & RegExpSearchable<0>> /`|\\[\\"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)
Expand Down

0 comments on commit 78bdda8

Please sign in to comment.