Open platform to collect and prioritize feedback
fix: update markdown service to avoid malicious redirects (#774)
Mohamed ELBARCHANY6ad67ff65073
diff --git a/public/services/markdown.spec.ts b/public/services/markdown.spec.tsindex bab7d10ff..04085d2fc 100644--- a/public/services/markdown.spec.ts+++ b/public/services/markdown.spec.ts@@ -3,8 +3,8 @@ import * as markdown from "./markdown";const testCases = [{input: "Visit [GitHub](https://github.com) to learn more.",- expectedFull: '<p>Visit <a target="_blank" href="https://github.com">GitHub</a> to learn more.</p>',- expectedSimple: '<p>Visit <a target="_blank" href="https://github.com">GitHub</a> to learn more.</p>'+ expectedFull: '<p>Visit <a target="_blank" rel="noopener" href="https://github.com">GitHub</a> to learn more.</p>',+ expectedSimple: '<p>Visit <a target="_blank" rel="noopener" href="https://github.com">GitHub</a> to learn more.</p>'},{input: "My Picture ",diff --git a/public/services/markdown.ts b/public/services/markdown.tsindex 3982e88f9..77745b9ee 100644--- a/public/services/markdown.ts+++ b/public/services/markdown.ts@@ -15,7 +15,7 @@ DOMPurify.setConfig({const link = (href: string, title: string, text: string) => {const titleAttr = title ? ` title=${title}` : "";- return `<a href="${href}"${titleAttr} target="_blank">${text}</a>`;+ return `<a href="${href}"${titleAttr} rel="noopener" target="_blank">${text}</a>`;};const simpleRenderer = new marked.Renderer();