Text: Markdown parser/renderer and HTML escaping #58

Closed
opened 2026-12-04 09:51:30 +00:00 by faumaray · 1 comment
Owner

Context: Forge M10 renders issue/comment Markdown. VoidLibrary has no Markdown parser and no HTML escaper (Void/Text/Html.hpp exists but was not confirmed to provide escaping), so Forge must own a bounded CommonMark subset.

Need (optional, reusable): a bounded CommonMark-subset parser and a safe HTML renderer that escapes by default and allow-lists constructs (no raw HTML), plus an HTML escape helper if Text/Html.hpp lacks one.

Tests/gate: CommonMark examples for the supported subset, hostile input (script tags, javascript: links, nested/malformed constructs), and strict input/output bounds. Forge proceeds with a Forge-side implementation until this lands.

Context: Forge M10 renders issue/comment Markdown. VoidLibrary has no Markdown parser and no HTML escaper (`Void/Text/Html.hpp` exists but was not confirmed to provide escaping), so Forge must own a bounded CommonMark subset. Need (optional, reusable): a bounded CommonMark-subset parser and a safe HTML renderer that escapes by default and allow-lists constructs (no raw HTML), plus an HTML escape helper if `Text/Html.hpp` lacks one. Tests/gate: CommonMark examples for the supported subset, hostile input (script tags, javascript: links, nested/malformed constructs), and strict input/output bounds. Forge proceeds with a Forge-side implementation until this lands.
Author
Owner

Implemented in 549c7cf on main.

  • Void/Text/Markdown.hpp: bounded CommonMark-subset parser + safe HTML renderer. Blocks: ATX/setext headings, paragraphs, fenced code, thematic breaks, block quotes, bullet/ordered lists. Inline: emphasis/strong, code spans, links, images, autolinks, escapes, hard breaks.
  • Raw HTML is never passed through (always escaped). Link/image destinations are allow-listed (http/https/mailto or relative); javascript:, data:, vbscript: and entity-smuggled variants are dropped to their label text.
  • MarkdownLimits bounds input size, output size, block count and nesting depth.
  • Void/Text/Html.hpp gained html_escape (it previously only had html_unescape).
  • Tests: tests/standalone/Text/Markdown.cpp (CommonMark examples for the supported subset, hostile input, and all four limits) plus html_escape cases in Text/Encoding.cpp. Text+Testing suite: 596 tests, 593 passed, 3 skipped, 0 failed.
Implemented in 549c7cf on `main`. - `Void/Text/Markdown.hpp`: bounded CommonMark-subset parser + safe HTML renderer. Blocks: ATX/setext headings, paragraphs, fenced code, thematic breaks, block quotes, bullet/ordered lists. Inline: emphasis/strong, code spans, links, images, autolinks, escapes, hard breaks. - Raw HTML is never passed through (always escaped). Link/image destinations are allow-listed (http/https/mailto or relative); `javascript:`, `data:`, `vbscript:` and entity-smuggled variants are dropped to their label text. - `MarkdownLimits` bounds input size, output size, block count and nesting depth. - `Void/Text/Html.hpp` gained `html_escape` (it previously only had `html_unescape`). - Tests: `tests/standalone/Text/Markdown.cpp` (CommonMark examples for the supported subset, hostile input, and all four limits) plus `html_escape` cases in `Text/Encoding.cpp`. Text+Testing suite: 596 tests, 593 passed, 3 skipped, 0 failed.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Void/Library#58