Repository navigation
fix(site): raw HTML in CHANGELOG.md or ROADMAP.md would go live - #7
Conversation
Astro's renderMarkdown passes raw HTML through, so a tag written as text outside backticks in Parsec's CHANGELOG or ROADMAP, such as <template shadowrootmode>, would become a live element on /changelog/ or /roadmap/. That is what broke netweir.com's changelog. Parsec's files keep such tags in code today; the loader now fails the build if either renders a live <template>, <script>, <iframe>, <object> or <embed>, naming the file and the tag.
foothillsdigital
left a comment
There was a problem hiding this comment.
Approving f5369cf. It catches the accident it's meant for, a release note's tag losing its backticks, and names the file and the tag. The regex runs on the rendered HTML, case-insensitive, so <template …> inside <code> passes and a bare <template shadowrootmode> stops the build.
One suggestion, not blocking: a list of banned tags covers what's been seen so far, not the class. A stray <img src=x onerror=…>, <a href="javascript:…">, <svg onload=…>, <form action=…> or <meta http-equiv="refresh"> would all render. The CSP already stops inline handlers and javascript: URLs from running, so the real exposure is small. But CHANGELOG.md and ROADMAP.md never need raw HTML, so it's simpler to not render any. Escaping raw HTML in that loader (a remark or rehype step that turns html nodes into text, or rehype-sanitize with an empty allow list for elements outside Markdown's own set) would close the whole category, and the check here could then go. Fine as a follow-up.
Problem
netweir.com's changelog failed the header check because a release note's
<template shadowrootmode>became a live element (https://github.com/netweir/website/pull/41). parsec.tools renders Parsec's CHANGELOG.md and ROADMAP.md the same way: Astro'srenderMarkdownpasses raw HTML through. Parsec's files keep such tags in backticks today, so the check passes on main, but one missing pair of backticks would put a live element on/changelog/or/roadmap/.Change
The repo-Markdown loader in
apps/site/src/content.config.tsfails the build if either file renders a live<template>,<script>,<iframe>,<object>or<embed>. The error names the file and the tag.Tests
astro checkreports 0 errors.<li>a <template shadowrootmode> b</li>and not<code><template shadowrootmode></code>.attachShadowand 404 notes don't occur on main.