Expand description
UI-10: HTML the page may hold — {@html expr} draws the
expression’s text as HTML, and markdown(text) makes HTML of
markdown; both go through sanitize first.
The sanitizer is an allow-list: it parses the text into elements and
text, keeps a tag only when it is listed (ALLOWED_TAGS) and an
attribute only when it is listed for its tag (allowed_attr); a URL
attribute keeps only http:, https:, #… and mailto: values. A tag
not listed is dropped and its text kept — except script, style,
iframe, object, embed, noscript, template, svg and math,
dropped with everything inside. What it answers is a tree the engine
draws through the renderer: no HTML string reaches the page.
Enums§
- HNode
- A sanitized node.
Constants§
- ALLOWED_
ATTRS - Every
(tag, attribute)kept;*is any allowed tag. Widening it is a deliberate edit (html/tests.rs pins it). - ALLOWED_
TAGS - The tags kept.
- HOUSE_
ATTRS - The plain-text attributes a house mark keeps beside
data-*(andid, kept asdata-id: an element’sidnames a global onwindow).
Functions§
- allowed_
attr - Whether
attris kept ontag(ALLOWED_ATTRS; on a house mark,house_attr). - custom_
tag - EDITOR-9: a custom element’s name — letters, digits and
-, with a-, beginning with a letter (volt-poll,x-new); not a house mark’s (those stay themselves). - house_
attr - Whether a house mark keeps
attr: adata-*(letters, digits,-) but the bound mark’s four, or one ofHOUSE_ATTRS. No handler, no style, no URL. - house_
tag - EDITOR-8: a house mark —
m-<name>(m-summary,m-field,m-decision, …), letters, digits and-after them-. A tenant’s body draws its marks as cards in CSS (the element is inert: no script defines it here, and nothing on it loads or runs), so the tag is kept with the plain-text attributes its card reads (house_attr) and nothing else. - markdown
- Markdown as HTML (CommonMark with tables and strikethrough); raw HTML in it passes through, to be sanitized where it is drawn.
- sanitize
html, parsed and kept to the allow-list.- to_html
- The nodes as HTML text (escaped), for the tests and the console.