From 29845c187e0b0d13fe6435b6259a15cad2d22fd7 Mon Sep 17 00:00:00 2001
From: Conor Bronsdon <120674402+conorbronsdon@users.noreply.github.com>
Date: Sun, 5 Jul 2026 23:11:19 -0700
Subject: [PATCH] fix: harden against confirmed review findings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Make _strip_tags quote-aware so a raw `>` inside a quoted attribute of
raw HTML in an image description cannot terminate the tag early and break
out of the generated alt="…" attribute (injection-prone unbalanced HTML).
Add a regression test covering double/single-quoted attributes and a
nested
.
Document in SECURITY.md that output is NOT sanitized: raw HTML and
javascript:/data: URLs pass through verbatim per CommonMark, so rendering
untrusted markdown into a live page is a stored-XSS risk that callers must
sanitize themselves.
Co-Authored-By: Claude
---
SECURITY.md | 24 ++++++++++++++++++++++--
src/markdown/inline.mojo | 25 +++++++++++++++++++++----
test/test_markdown.mojo | 22 ++++++++++++++++++++++
3 files changed, 65 insertions(+), 6 deletions(-)
diff --git a/SECURITY.md b/SECURITY.md
index 0a0c920..fa64ba6 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -2,8 +2,28 @@
mojo-markdown is a pure-Mojo CommonMark parser and HTML renderer with no
network access, no authentication, and no secrets handling — it reads
-markdown text and returns rendered HTML or an AST. The main risk
-surface is malformed or adversarial input causing a crash or hang.
+markdown text and returns rendered HTML or an AST.
+
+## Output is NOT sanitized
+
+Per the [CommonMark spec](https://spec.commonmark.org/), raw inline and
+block HTML, as well as `javascript:`, `data:`, and other arbitrary URL
+schemes in links and images, pass through to the output **verbatim**.
+mojo-markdown does **not** sanitize its output. Rendering untrusted
+markdown and inserting the result into a live page is a stored-XSS risk:
+an author can embed `