Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-TRUST-042

The sanitizer rewrites links and records each removal

When the sanitizer finds a link in a page, it SHALL keep an anchor or an http, https or mailto address as the href, turn a relative or wiki request into the href # that the host routes from data-sphinx-preview-navigation, remove the address of a blocked request (and name the reason in its title when it has none), remove a linked stylesheet (recording the diagnostic that it is ignored when the file is inside the roots), and record each removal or rewrite as a diagnostic with a code, a message and the value on the record of the page, without showing it in the status area of the preview.

Part of StRS-MDOKFSTUDIO-TRUST-006, outside the paths drawn on its map.

Scenarios 6

The situations the tests check; open one to read it.

nominalAnchor and external addresses
InputOutcome
a link with href #sectionthe href is #section and data-sphinx-preview-navigation holds #section
https://example.test/docsthe address is kept as the href, with the original request in data-sphinx-preview-navigation
mailto:docs@example.testthe address is kept as the href, with the original request in data-sphinx-preview-navigation
nominalRelative and wiki links are routed by the host
InputOutcome
a link with href chapter-two.mdthe href is # and data-sphinx-preview-navigation is chapter-two.md
a link whose request is wiki:Some Pagethe href is # and the request is kept in data-sphinx-preview-navigation
refusalBlocked links
InputOutcome
a link with href javascript:alert(1)no href remains; the request is only in data-sphinx-preview-navigation; the diagnostic blocked-navigation is recorded (message Removed navigation outside the preview policy.)
a link with href # followed by a spaceno href remains; the diagnostic blocked-navigation is recorded
an xlink:href the link rules block (an SVG link)no href remains; the request is only in data-sphinx-preview-navigation, as for an HTML link; the diagnostic blocked-navigation is recorded
an xlink:href the link rules allow (an SVG link)the address is kept and the request is in data-sphinx-preview-navigation; the host routes the click, as for an HTML link
boundaryLinked stylesheet
InputOutcome
a link element for theme.css inside the rootsthe element is removed; the page build records the diagnostic blocked-stylesheet (message Ignored a linked stylesheet; the preview supplies its own theme.)
a link element for a file outside the rootsthe element is removed with the diagnostic blocked-stylesheet (message Removed a stylesheet outside staged output.)
nominalRemovals are recorded on the record of the page
Givena document whose HTML holds an iframe
an image whose reference leaves the roots
Whenthe preview renders
the preview renders
Thenthe record of the page holds the diagnostic blocked-active-element with its message
the record holds the diagnostic blocked-resource with the reference as its value (message Removed a resource outside staged output.)
refusalRemovals are not shown to the reader
Givena document whose HTML holds an iframe or an image outside the roots
a document with a missing include
Whenthe preview renders
the preview renders
Thenthe page and the status area show no trace of the removal
the status area lists the render diagnostic

Implemented in 3

Tested by 4