mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-09-15 07:05:26 +02:00
fix: sanitize Org previews before trusting rendered HTML
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"core.min.js": "core.6332b3c288.min.js",
|
"core.min.js": "core.6332b3c288.min.js",
|
||||||
"vendor.min.js": "vendor.a5d94d956f.min.js",
|
"vendor.min.js": "vendor.1020f4867e.min.js",
|
||||||
"mermaid.min.js": "mermaid.f848a72d16.min.js",
|
"mermaid.min.js": "mermaid.f848a72d16.min.js",
|
||||||
"all.min.css": "all.99ce8f3e14.min.css"
|
"all.min.css": "all.99ce8f3e14.min.css"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2961,7 +2961,7 @@ angular
|
|||||||
suppressSubScriptHandling: true,
|
suppressSubScriptHandling: true,
|
||||||
suppressAutoLink: false,
|
suppressAutoLink: false,
|
||||||
});
|
});
|
||||||
$scope.content = $sce.trustAsHtml(orgHTMLDocument.toString());
|
$scope.content = $sce.trustAsHtml(DOMPurify.sanitize(orgHTMLDocument.toString()));
|
||||||
$scope.type = "html";
|
$scope.type = "html";
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -66,4 +66,12 @@ describe("frontend production regressions", function () {
|
|||||||
expect(template).to.include("treeNodes");
|
expect(template).to.include("treeNodes");
|
||||||
expect(h.scope.treeNodes[0].path).to.equal("/constructor/index.js");
|
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");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user