浏览代码

Merge pull request #3912 from microsoft/hediet/b/defensive-platypus

Escape $ in template strings
Henning Dieterichs 2 年之前
父节点
当前提交
68f779a782
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      website/src/website/pages/playground/PlaygroundModel.ts

+ 4 - 1
website/src/website/pages/playground/PlaygroundModel.ts

@@ -251,7 +251,10 @@ export class PlaygroundModel {
 		);
 		);
 		debugger;
 		debugger;
 		const js = this.js;
 		const js = this.js;
-		const str = value.replaceAll("\\", "\\\\").replaceAll("`", "\\`");
+		const str = value
+			.replaceAll("\\", "\\\\")
+			.replaceAll("$", "\\$")
+			.replaceAll("`", "\\`");
 		const newJs = js.replace(regexp, "$1" + str + "`");
 		const newJs = js.replace(regexp, "$1" + str + "`");
 		const autoReload = this.settings.autoReload;
 		const autoReload = this.settings.autoReload;
 		this.settings.autoReload = false;
 		this.settings.autoReload = false;