0261. HTML escaping and request-value decoding plugin
- Status: Accepted (maintainer, 2026-11-22; web toolkit WT0)
- Date: 2026-11-17
- Plan: M-HTTP.10, M-HTTP.11
- Review: Forge P3;
PLAN-http
Context
ADR-0164 keeps protocol policy in Harness plugins. Hosting H7 needs escaped, read-only HTML; cookie write UI remains deferred under ADR-0205. The http DOCS budget is nearly full and its emit-C digests must stay unchanged.
Decision
- Separate capability-free
htmllibrary, version 0.1.0, no dependencies.libexposes only version;htmlprovides escaping/building (P3a),urlandcookieprovide request-value decoding later (P3b). Htmlis a newtype with file-private constructor. Onlytext,element,void,concatcreate values. No raw-HTML API. Fixed CSS/JS are files, referenced with link href / script src; documents are HTML5 (<!DOCTYPE html>).- Escape text
& < >and additionally attribute" 'using named references& < > " ';'is valid HTML5. NUL is unchanged. - Validate lowercase names, forbidden elements, void usage, external-only scripts, forbidden/duplicate attributes, then URL safety, in that order. The exact lists and fixed error strings are in Forge PLAN-p3 P3a; no compiler diagnostic codes. Attributes retain caller order and quoted empty values.
- Percent decoding is strict
%HHto UTF-8;+means space only in forms. Form duplicates retain order; lookup is first-wins, matching query_param. - Cookie parsing reads request Cookie only, with no decoding.
Out of scope: Set-Cookie, sessions, CSRF, browser writes (F7/ADR-0205 stays open), multipart, a router, templates, sanitizing untrusted HTML. No choices about TLS, runner isolation, ADRs 0204–0207, YAML importer, issues/review/wiki.
Alternatives considered
- Extend http: exceeds its DOCS budget and churns digests.
- String templates: injection by default.
- Numeric references: named references read better and are equally safe in HTML5.
- raw() escape hatch: H7 forbids rendering repository HTML/SVG as markup.
Consequences
Pages compose escaped, typed fragments with differential plugin goldens. Repository HTML/SVG must be wrapped in text, never interpreted as markup. http.wire.query_param and http.files.safe_path remain raw and byte-identical.
Open questions (chosen defaults)
- Name html, not web/web_html; future rename costs imports only.
- Use ', not ', unless a non-HTML5 consumer appears.
- Reject the whole Cookie header on any invalid pair, rather than skip pairs.
- Keep form duplicates in order with first-wins lookup.
- Allow decoded %2F inside a segment after splitting; filesystem apps still use safe_path.
- Leave PLAN-hosting unedited; Maintainer decides whether F1 uses path_segments for GET selectors instead of its planned POST JSON.
- No Set-Cookie parsing in P3; client-side only, no current consumer.
- Do not update the AGENTS.md repo map in this task.