Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-GFM-034

Colour spans keep safe colours only

When a span style declares color or background-color as a named colour or keyword, hex, rgb()/rgba() or hsl()/hsla() (comma or space form), the extension SHALL keep the colours as data attributes and apply them on the page only after revalidating each value with the same grammar, removing var(), url(), expression(), !important, comments, escapes, injected declarations and other properties, and recording the diagnostic removed-unsafe-style ('Removed unsafe style attribute.') for a removed declaration.

Part of StRS-MDOKFSTUDIO-GFM-002, outside the paths drawn on its map.

Scenarios 5

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

nominalHex and rgba kept
Givena span with style 'color:#f00; background-color: rgba(0,0,0,50%)' or 'color: red; background-color: hsl(0,0%,0%)', also nested, in a pipe-table cell and in a raw HTML table cell
Whenthe preview is rendered
Thenboth colours are exposed as data attributes
refusalUnsafe values removed
InputOutcome
`color: red; background: var(--x) !important`red is kept; the rest is removed and the text kept
`color: revert`, `color: red !important`, `color: red} body{x:y`, `color: r\65 d`the value is removed and the text kept
`rgb(0, 0 0)` (comma and space mixed), `rgb(0 0 0 0.5)` (no slash), `rgb(256 0 0)`the value is removed and the text kept
`rgb(0 0 0 / 50%)`, `hsl(120 100% 50%)`, `currentcolor`the value is kept
boundaryDiagnostic for removed declarations
InputOutcome
span style 'color:#f00; position:fixed'the diagnostic removed-unsafe-style ('Removed unsafe style attribute.') is recorded
span style 'color:#f00'no diagnostic is recorded
nominalThe page applies valid colours
Givena span with data-okf-color '#f00' under the preview content
Whencolours are applied
Thenthe element style color is set through the CSSOM
refusalHand-edited invalid attribute
Givena span with data-okf-color 'url(x)'
Whencolours are applied
Thenno style is set

Implemented in 3

Tested by 6

Replaces

SwRS-MDOKFSTUDIO-GFM-035The page revalidates span colours before applying superseded superseded by SwRS-MDOKFSTUDIO-GFM-034 Markdown file
SwRS-MDOKFSTUDIO-GFM-036Removed span styles record a diagnostic superseded superseded by SwRS-MDOKFSTUDIO-GFM-034 Markdown file