feat: escape raw HTML in stranger doc comments (torb doc --escape-html) #481
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/234-safe-html"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #234
Summary
std/markdown:MarkdownDocument.safeHtml()besidehtml(). Raw HTML blocks and inline spans are written as escaped text; a link or image destination with the schemejavascript:,vbscript:ordata:(case-insensitive, after trimming and removing control characters and whitespace) becomes an emptyhref/src.html()is unchanged.torb doc --escape-htmlthreads that choice throughmarkdownHtmland the site generator; without the flag the output is what it was. Parsed, listed in the usage text and documented indocs/tooling/torb-doc.md(synopsis, flag list, a paragraph under "The site");skills/copies edited by hand to match the generated form.--escape-htmltotorb doc --output. A toolchain that does not know the flag refuses the command, so the version isfailed(fails closed); RELEASE.md section 7.7 and the registry README name both.Seed: not touched (no syntax, native, build-used driver flag or looked-up std name; the compiler's own build never passes the flag).
Acceptance criteria
std/markdowntests, group "safe HTML": hostile blocks and spans as escaped text, script-scheme destinations empty, ordinary destinations unchanged. CommonMark examples run throughhtml()as before. Status: written, awaiting CI.compiler/tests/reference.test.trb: a doc comment with a raw HTML block and span renders as text with--escape-html, as HTML without it. Status: written, awaiting CI.docs/tooling/torb-doc.md;docs/standard-library/markdown.mddocumentssafeHtml. Theskills/copies were edited by hand (notorbon the worker), CI'sdocs skill --checkis the proof.--escape-html; RELEASE.md 7.7 names the flag and the fail-closed behaviour. The registry test has no argument-list assertion, so it now checks the stored page instead: a<script>in a doc comment is written as<script>.sh tools/gates.sh agreen in forge CI: pending, nothing was run locally (CI only).Test
Not run locally (no bootstrap/gates on the worker);
tools/check-commits.sh origin/main HEADis clean. Forge CI is the first run, so format or typo rounds are possible.3507d5672dce73eaf355Review of
ce73eaf(round 1). The approach is sound: escaping is applied at the single renderer choke point (HtmlRenderer.safe),html()and the default oftorb docstay unchanged, the registry fails closed on an older toolchain, scope matches #234, and the tests cover blocks, spans, scheme case/whitespace variants, unchanged destinations and the stored registry page. Two things to fix:[blocker] CI red on
ce73eaf:ci / tier A (linux-x64)fails in exactly one gate,format --check("2 of 1483 files would change"):compiler/tests/reference.test.trbandstd/markdown/src/html.trb. All other gates (docs skill/site check, compiler tests, std tests native+VM, tier B, registry, pdisc) are green. Runtorb formaton those two files and push;ci / gatesis red only because of this.[blocker] Documentation contradicts the behavior for
data:images.docs/tooling/torb-doc.md(and itsskills/torbscript-projects/...copy) says the flag blanks "data:other than an image". The implementation (hasScriptSchemeviaHtmlRenderer.uri) blanks everydata:destination, images included, and your own testsafe("") == ...src=\"\"...asserts that. Safer behavior is fine, but the doc must say so: drop "other than an image" in both copies (themarkdown.mdwording is already correct). Thedocs skill --checkstays green only if both copies are edited identically.Non-blocking: none. Re-review will check only these two points and the lines changed since.
ce73eaf355cbe8448a3dcbe8448a3daef67bcae7aef67bcae74bfb26e756Addressed review 430 in
4bfb26e(rebased onto mainf630c25):torb formatrun oncompiler/tests/reference.test.trbandstd/markdown/src/html.trb;torb format --checkis clean on all 9 changed.trbfiles.docs/tooling/torb-doc.mdand itsskills/copy now read "data:, images included" (edited identically, matchesmarkdown.mdand the implementation).pdisc checkis ok. Nothing else changed.Re-review of
4bfb26e(round 2). Earlier findings:ci / gatesandci / tier A (linux-x64)are green on this head, as are tier B, registry, pdisc and the playground.data:doc contradiction: fixed.docs/tooling/torb-doc.mdand itsskills/copy now read "data:, images included", edited identically, matchingmarkdown.mdand the implementation/test.Checklist: tests ok (std/markdown safe-HTML group, reference test, registry stored-page check); correctness ok (escaping at the single renderer choke point,
html()and the default oftorb docunchanged, registry fails closed on an older toolchain); scope = #234; no secrets or new services; no data/format change; docs updated; no new boundary.Non-blocking: none.