Markdown OKF-Schema Studio

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
InputOutcome
an iframeremoved with its content; the diagnostic blocked-active-element is recorded
an SVG foreignObjectremoved with its content; the diagnostic blocked-active-element is recorded
an embed, an object, a formremoved 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 foreignObjectthe image and the link stay
nominalStyle elements are removed
Givena page with a style element in the content
a raw table with a data-myst-table-style attribute
Whenthe page is sanitized
the page is sanitized
Thenthe element is gone and the diagnostic blocked-inline-style is recorded
the style survives only as the nonce stylesheet of SwRS-MDOKFSTUDIO-GFM-031
boundaryAutomatic refresh
InputOutcome
a meta element with http-equiv set to Refresh, with surrounding spacesremoved; the diagnostic blocked-refresh is recorded
a meta element whose http-equiv is refresh in any other letter caseremoved
a meta element that sets the viewportstays
refusalEvent, srcdoc and style attributes
InputOutcome
onload on the bodythe attribute is removed
onclick on an imagethe attribute is removed
style color red on a paragraphthe attribute is removed
srcdoc on an elementthe attribute is removed
the style of a span, the table style attributenot 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
InputOutcome
an img element with no alt attributeit carries alt with an empty value
an img element with alt set to imagethe alt text is kept
refusalElements and attributes outside the allow-list
InputOutcome
a page with a base elementremoved; the diagnostic blocked-element is recorded
a link element that is not a stylesheet, a template, a dialog, an element of an unknown nameremoved with their content; the diagnostic blocked-element is recorded
a paragraph with a data-example attribute, an image with a ping or formaction attributethe 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 attributethe 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
InputOutcome
50 000 sibling elements of an unknown nameall removed, each with the diagnostic blocked-element, in well under a second
Nesting of 10 000 levelsno error; content deeper than 256 levels is replaced by a visible marker and the diagnostic truncated-depth is recorded

Implemented in 2

Tested by 5