A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: add noreferrer to external markdown links to prevent 403 errors (#7360)
Myles Scolnick7c8070aa6249
diff --git a/frontend/src/plugins/core/__test__/sanitize.test.ts b/frontend/src/plugins/core/__test__/sanitize.test.tsindex 0cffbfe83e..3b9d6faa38 100644--- a/frontend/src/plugins/core/__test__/sanitize.test.ts+++ b/frontend/src/plugins/core/__test__/sanitize.test.ts@@ -64,7 +64,7 @@ describe("sanitizeHtml", () => {test("preserves safe anchor with target=_blank", () => {const html = '<a href="https://example.com" target="_blank">Link</a>';expect(sanitizeHtml(html)).toMatchInlineSnapshot(- `"<a href="https://example.com" target="_blank" rel="noopener">Link</a>"`,+ `"<a href="https://example.com" target="_blank" rel="noopener noreferrer">Link</a>"`,);});diff --git a/frontend/src/plugins/core/sanitize.ts b/frontend/src/plugins/core/sanitize.tsindex 8629570549..a8ee5e281c 100644--- a/frontend/src/plugins/core/sanitize.ts+++ b/frontend/src/plugins/core/sanitize.ts@@ -62,7 +62,7 @@ DOMPurify.addHook("afterSanitizeAttributes", (node) => {node.setAttribute("target", node.getAttribute(TEMPORARY_ATTRIBUTE) || "");node.removeAttribute(TEMPORARY_ATTRIBUTE);if (node.getAttribute("target") === "_blank") {- node.setAttribute("rel", "noopener");+ node.setAttribute("rel", "noopener noreferrer");}}});diff --git a/marimo/_output/md_extensions/external_links.py b/marimo/_output/md_extensions/external_links.pyindex b97238fc48..ef0ae511a9 100644--- a/marimo/_output/md_extensions/external_links.py+++ b/marimo/_output/md_extensions/external_links.py@@ -28,7 +28,7 @@ class ExternalLinksTreeProcessor(treeprocessors.Treeprocessor): # type: ignore[if parsed_url.scheme in ["http", "https"]:element.set("target", "_blank")- element.set("rel", "noopener")+ element.set("rel", "noopener noreferrer")class ExternalLinksExtension(Extension): # type: ignore[misc]diff --git a/tests/_output/test_md.py b/tests/_output/test_md.pyindex 9c3091cb11..3b46ff49b2 100644--- a/tests/_output/test_md.py+++ b/tests/_output/test_md.py@@ -73,7 +73,7 @@ def test_md_latex() -> None:def test_md_links() -> None:# Test external link conversionlink_input = "[Google](https://google.com)"- expected_output = '<span class="paragraph"><a href="https://google.com" rel="noopener" target="_blank">Google</a></span>' # noqa: E501+ expected_output = '<span class="paragraph"><a href="https://google.com" rel="noopener noreferrer" target="_blank">Google</a></span>' # noqa: E501assert _md(link_input, apply_markdown_class=False).text == (expected_output)