Behaviour SwRS-MDOKFSTUDIO-TRUST-036
The sanitizer removes active content and keeps the rest
When the sanitizer processes a page, it SHALL remove every embed, foreignObject, form, iframe, object and style element, every meta element whose http-equiv is refresh, and every attribute whose name starts with on or is srcdoc or style (except the style of a span and the table style attribute that other rules handle), give an img without an alt attribute an empty alt, and remove every element and attribute that is not on its list of supported ones, in time linear in the size of the page, and cut content nested deeper than 256 levels with a visible marker.
Step 2 of path 1 in StRS-MDOKFSTUDIO-TRUST-006: from “The scripts of the document are gone” to “The raw HTML is inert”.
Scenarios 7
The situations the tests check; open one to read it.
nominalActive elements are removed with their content
| Input | Outcome |
|---|---|
| an iframe | removed with its content; the diagnostic blocked-active-element is recorded |
| an SVG foreignObject | removed with its content; the diagnostic blocked-active-element is recorded |
| an embed, an object, a form | removed with their content (the five names embed, foreignObject, form, iframe and object are covered; embed, object and form are untested) |
| an image and a link beside the iframe and the foreignObject | the image and the link stay |
nominalStyle elements are removed
a raw table with a data-myst-table-style attribute
the page is sanitized
the style survives only as the nonce stylesheet of SwRS-MDOKFSTUDIO-GFM-031
boundaryAutomatic refresh
| Input | Outcome |
|---|---|
| a meta element with http-equiv set to Refresh, with surrounding spaces | removed; the diagnostic blocked-refresh is recorded |
| a meta element whose http-equiv is refresh in any other letter case | removed |
| a meta element that sets the viewport | stays |
refusalEvent, srcdoc and style attributes
| Input | Outcome |
|---|---|
| onload on the body | the attribute is removed |
| onclick on an image | the attribute is removed |
| style color red on a paragraph | the attribute is removed |
| srcdoc on an element | the attribute is removed |
| the style of a span, the table style attribute | not removed here; handled by SwRS-MDOKFSTUDIO-GFM-034 and SwRS-MDOKFSTUDIO-GFM-031 |
The diagnostic blocked-event-attribute is recorded for each removal.
boundaryAlternative text of an image
| Input | Outcome |
|---|---|
| an img element with no alt attribute | it carries alt with an empty value |
| an img element with alt set to image | the alt text is kept |
refusalElements and attributes outside the allow-list
| Input | Outcome |
|---|---|
| a page with a base element | removed; the diagnostic blocked-element is recorded |
| a link element that is not a stylesheet, a template, a dialog, an element of an unknown name | removed with their content; the diagnostic blocked-element is recorded |
| a paragraph with a data-example attribute, an image with a ping or formaction attribute | the attribute is removed; the diagnostic blocked-attribute is recorded |
| a paragraph with a class, an aria-label, a data-line or a data-okf-color attribute | the attribute stays |
The list holds the elements and attributes the supported rendering needs: the HTML text, list, table, media and form elements, the basic SVG and MathML elements, the aria-* attributes and the data attributes written by the renderer (data-line, data-end-line, data-line-number, data-footnote*, data-plantuml-* and the prefixes data-sphinx-, data-okf- and data-myst-).
boundaryMany removals and deep nesting
| Input | Outcome |
|---|---|
| 50 000 sibling elements of an unknown name | all removed, each with the diagnostic blocked-element, in well under a second |
| Nesting of 10 000 levels | no error; content deeper than 256 levels is replaced by a visible marker and the diagnostic truncated-depth is recorded |