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
| Input | Outcome |
|---|---|
| a link with href #section | the href is #section and data-sphinx-preview-navigation holds #section |
| https://example.test/docs | the address is kept as the href, with the original request in data-sphinx-preview-navigation |
| mailto:docs@example.test | the address is kept as the href, with the original request in data-sphinx-preview-navigation |
nominalRelative and wiki links are routed by the host
| Input | Outcome |
|---|---|
| a link with href chapter-two.md | the href is # and data-sphinx-preview-navigation is chapter-two.md |
| a link whose request is wiki:Some Page | the href is # and the request is kept in data-sphinx-preview-navigation |
refusalBlocked links
| Input | Outcome |
|---|---|
| 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 space | no 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
| Input | Outcome |
|---|---|
| a link element for theme.css inside the roots | the 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 roots | the element is removed with the diagnostic blocked-stylesheet (message Removed a stylesheet outside staged output.) |
nominalRemovals are recorded on the record of the page
an image whose reference leaves the roots
the preview renders
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
a document with a missing include
the preview renders
the status area lists the render diagnostic