diff --git a/server/commands/documentImporter.test.ts b/server/commands/documentImporter.test.ts index f35e23cdf..c7a85cf3b 100644 --- a/server/commands/documentImporter.test.ts +++ b/server/commands/documentImporter.test.ts @@ -213,4 +213,76 @@ describe("documentImporter", () => { expect(error).toEqual("File type executable/zip not supported"); }); + + it("should escape dollar signs in HTML input", async () => { + const user = await buildUser(); + const fileName = "test.html"; + const content = ` + + +
+$100
+ + + `; + const response = await documentImporter({ + user, + mimeType: "text/html", + fileName, + content, + ip, + }); + expect(response.text).toEqual("\\$100"); + }); + + it("should not escape dollar signs in inline code in HTML input", async () => { + const user = await buildUser(); + const fileName = "test.html"; + const content = ` + + + +echo $foo
+
+
+ `;
+ const response = await documentImporter({
+ user,
+ mimeType: "text/html",
+ fileName,
+ content,
+ ip,
+ });
+ expect(response.text).toEqual("`echo $foo`");
+ });
+
+ it("should not escape dollar signs in code blocks in HTML input", async () => {
+ const user = await buildUser();
+ const fileName = "test.html";
+ const content = `
+
+
+
+ echo $foo
+
+
+ `;
+ const response = await documentImporter({
+ user,
+ mimeType: "text/html",
+ fileName,
+ content,
+ ip,
+ });
+ expect(response.text).toEqual("```\necho $foo\n```");
+ });
});
diff --git a/server/commands/documentImporter.ts b/server/commands/documentImporter.ts
index f014280be..9b5db20df 100644
--- a/server/commands/documentImporter.ts
+++ b/server/commands/documentImporter.ts
@@ -63,10 +63,6 @@ async function documentImporter({
// to match our hardbreak parser.
text = text.trim().replace(/