On this page

0261. HTML escaping and request-value decoding plugin

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

  1. Separate capability-free html library, version 0.1.0, no dependencies. lib exposes only version; html provides escaping/building (P3a), url and cookie provide request-value decoding later (P3b).
  2. Html is a newtype with file-private constructor. Only text, element, void, concat create values. No raw-HTML API. Fixed CSS/JS are files, referenced with link href / script src; documents are HTML5 (<!DOCTYPE html>).
  3. Escape text & < > and additionally attribute " ' using named references &amp; &lt; &gt; &quot; &apos;; &apos; is valid HTML5. NUL is unchanged.
  4. 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.
  5. Percent decoding is strict %HH to UTF-8; + means space only in forms. Form duplicates retain order; lookup is first-wins, matching query_param.
  6. 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

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)

  1. Name html, not web/web_html; future rename costs imports only.
  2. Use ', not ', unless a non-HTML5 consumer appears.
  3. Reject the whole Cookie header on any invalid pair, rather than skip pairs.
  4. Keep form duplicates in order with first-wins lookup.
  5. Allow decoded %2F inside a segment after splitting; filesystem apps still use safe_path.
  6. Leave PLAN-hosting unedited; Maintainer decides whether F1 uses path_segments for GET selectors instead of its planned POST JSON.
  7. No Set-Cookie parsing in P3; client-side only, no current consumer.
  8. Do not update the AGENTS.md repo map in this task.