fix: sanitize Org previews before trusting rendered HTML

This commit is contained in:
tdurieux
2026-09-06 10:46:44 +02:00
parent cf58aa330b
commit b2dfda1838
4 changed files with 11 additions and 3 deletions
+8
View File
@@ -66,4 +66,12 @@ describe("frontend production regressions", function () {
expect(template).to.include("treeNodes");
expect(h.scope.treeNodes[0].path).to.equal("/constructor/index.js");
});
it("sanitizes Org output before trusting it", async function () {
const h = explorer(); let untrusted;
h.context.Org = { Parser: function () { this.parse = () => ({ convert: () => ({ toString: () => '<img onerror="probe()">' }) }); }, ConverterHTML: {} };
h.context.contentAbs2Relative = x => x;
h.context.DOMPurify = { sanitize: html => { untrusted = html; return "sanitized"; } };
h.navigate("file.org"); h.requests.at(-1).resolve({ data: "org source", headers: () => "text/plain" }); await h.flush();
expect(untrusted).to.include("onerror"); expect(h.scope.content).to.equal("sanitized");
});
});