fix: escape markdown preview HTML (#52)
CI / lint (pull_request) Successful in 7s
CI / build-frontend (pull_request) Successful in 4s

This commit is contained in:
timmy committed 2026-08-05 23:48:27 +00:00
1 parent a6732b9c93
commit f63c8c39b1
4 files changed
+59 -8

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
import json
import subprocess
from pathlib import Path
RENDERER = Path(__file__).parent.parent / "frontend" / "markdown.js"
def test_markdown_renderer_escapes_raw_html_before_rendering_heading():
payload = "# <img src=x onerror=alert(document.domain)>"
script = (
f"const render = require({json.dumps(str(RENDERER))});"
f"process.stdout.write(render({json.dumps(payload)}));"
)
result = subprocess.run(
["node", "-e", script],
check=True,
capture_output=True,
text=True,
)
assert result.stdout == (
"<h1>&lt;img src=x onerror=alert(document.domain)&gt;</h1>"
)