KsesCss final class
Minn\Support\KsesCss · public/minn/src/Minn/Support/KsesCss.php · 138 lines
The style attribute as kses keeps it (safecss_filter_attr): each declaration whose property is on the list stays, a value's url() only on the properties that may hold one and only with a safe scheme, the gradients and CSS functions the reference allows, and nothing that could end the declaration. Plugins widen the list and the verdict through the hooks the facade wires in (safe_style_css, safecss_filter_attr_allow_css).
Constants and properties
| private | CSS_PROPERTIES = array ( 0 => 'background', 1 => 'background-color', 2 => 'background-image', 3 => 'background-position', 4 => 'background-repeat', 5 => 'background-size', 6 => 'background-attachment', 7 => 'background-blend-mode', 8 => 'border', 9 => 'border-radius', 10 => 'border-width', 11 => 'border-color', 12 => 'border-style', 13 => 'border-right', 14 => 'border-right-color', 15 => 'border-right-style', 16 => 'border-right-width', 17 => 'border-bottom', 18 => 'border-bottom-color', 19 => 'border-bottom-left-radius', 20 => 'border-bottom-right-radius', 21 => 'border-bottom-style', 22 => 'border-bottom-width', 23 => 'border-bottom-right-radius', 24 => 'border-bottom-left-radius', 25 => 'border-left', 26 => 'border-left-color', 27 => 'border-left-style', 28 => 'border-left-width', 29 => 'border-top', 30 => 'border-top-color', 31 => 'border-top-left-radius', 32 => 'border-top-right-radius', 33 => 'border-top-style', 34 => 'border-top-width', 35 => 'border-top-left-radius', 36 => 'border-top-right-radius', 37 => 'border-spacing', 38 => 'border-collapse', 39 => 'caption-side', 40 => 'columns', 41 => 'column-count', 42 => 'column-fill', 43 => 'column-gap', 44 => 'column-rule', 45 => 'column-span', 46 => 'column-width', 47 => 'display', 48 => 'color', 49 => 'filter', 50 => 'font', 51 => 'font-family', 52 => 'font-size', 53 => 'font-style', 54 => 'font-variant', 55 => 'font-weight', 56 => 'letter-spacing', 57 => 'line-height', 58 => 'text-align', 59 => 'text-decoration', 60 => 'text-indent', 61 => 'text-transform', 62 => 'white-space', 63 => 'height', 64 => 'min-height', 65 => 'max-height', 66 => 'width', 67 => 'min-width', 68 => 'max-width', 69 => 'margin', 70 => 'margin-right', 71 => 'margin-bottom', 72 => 'margin-left', 73 => 'margin-top', 74 => 'margin-block-start', 75 => 'margin-block-end', 76 => 'margin-inline-start', 77 => 'margin-inline-end', 78 => 'padding', 79 => 'padding-right', 80 => 'padding-bottom', 81 => 'padding-left', 82 => 'padding-top', 83 => 'padding-block-start', 84 => 'padding-block-end', 85 => 'padding-inline-start', 86 => 'padding-inline-end', 87 => 'flex', 88 => 'flex-basis', 89 => 'flex-direction', 90 => 'flex-flow', 91 => 'flex-grow', 92 => 'flex-shrink', 93 => 'flex-wrap', 94 => 'gap', 95 => 'column-gap', 96 => 'row-gap', 97 => 'grid-template-columns', 98 => 'grid-auto-columns', 99 => 'grid-column-start', 100 => 'grid-column-end', 101 => 'grid-column', 102 => 'grid-column-gap', 103 => 'grid-template-rows', 104 => 'grid-auto-rows', 105 => 'grid-row-start', 106 => 'grid-row-end', 107 => 'grid-row', 108 => 'grid-row-gap', 109 => 'grid-gap', 110 => 'justify-content', 111 => 'justify-items', 112 => 'justify-self', 113 => 'align-content', 114 => 'align-items', 115 => 'align-self', 116 => 'clear', 117 => 'cursor', 118 => 'direction', 119 => 'float', 120 => 'list-style-type', 121 => 'object-fit', 122 => 'object-position', 123 => 'opacity', 124 => 'overflow', 125 => 'vertical-align', 126 => 'writing-mode', 127 => 'position', 128 => 'top', 129 => 'right', 130 => 'bottom', 131 => 'left', 132 => 'z-index', 133 => 'box-shadow', 134 => 'aspect-ratio', 135 => 'container-type', 136 => 'fill', 137 => 'fill-opacity', 138 => 'fill-rule', 139 => 'stroke', 140 => 'stroke-dasharray', 141 => 'stroke-dashoffset', 142 => 'stroke-linecap', 143 => 'stroke-linejoin', 144 => 'stroke-miterlimit', 145 => 'stroke-opacity', 146 => 'stroke-width', 147 => 'color-interpolation', 148 => 'color-interpolation-filters', 149 => 'paint-order', 150 => 'stop-color', 151 => 'stop-opacity', 152 => 'flood-color', 153 => 'flood-opacity', 154 => 'lighting-color', 155 => 'marker', 156 => 'marker-end', 157 => 'marker-mid', 158 => 'marker-start', 159 => 'clip-path', 160 => 'clip-rule', 161 => 'mask', 162 => 'mask-type', 163 => 'cx', 164 => 'cy', 165 => 'r', 166 => 'rx', 167 => 'ry', 168 => 'x', 169 => 'y', 170 => 'd', 171 => 'alignment-baseline', 172 => 'baseline-shift', 173 => 'dominant-baseline', 174 => 'glyph-orientation-horizontal', 175 => 'glyph-orientation-vertical', 176 => 'text-anchor', 177 => 'unicode-bidi', 178 => 'word-spacing', 179 => 'font-size-adjust', 180 => 'font-stretch', 181 => 'color-rendering', 182 => 'image-rendering', 183 => 'shape-rendering', 184 => 'text-rendering', 185 => 'vector-effect', 186 => 'transform', 187 => 'transform-origin', 188 => 'pointer-events', 189 => 'visibility', 190 => '--*', ) | The properties style attributes keep, as the reference lists them before safe_style_css (probe safety-filters); --* stands for custom properties. |
| private | CSS_FUNCTIONS = '/\\b(?:var|calc|min|max|minmax|clamp|repeat|rotate(?:X|Y|Z|3d)?|translate(?:X|Y|Z|3d)?|scale(?:X|Y|Z|3d)?|skew(?:X|Y)?|matrix(?:3d)?|perspective|inset|circle|ellipse|polygon|path)(\\((?:[^()]|(?1))*\\))/' | The CSS functions a value may use (transforms, shapes and the math ones), whatever they hold. |
| private | CSS_GRADIENTS = '/\\b(?:repeating-)?(?:linear|radial|conic)-gradient(\\((?:[^()]|(?1))*\\))/' | The gradients a background may use. |
| private | CSS_URL_PROPERTIES = array ( 0 => 'background', 1 => 'background-image', 2 => 'cursor', 3 => 'filter', 4 => 'mask', 5 => 'clip-path', ) | The properties that may use a url(). |
| private | CSS_GRADIENT_PROPERTIES = array ( 0 => 'background', 1 => 'background-image', ) | The properties that may use a gradient. |
| private | static ?array $styleHooks |
Public
| static | style(string $style): string# | A style attribute's value with only the listed properties kept. | ||||||
| static | styleHooks(Closure $properties, Closure $allow): void# | The runtime's say over style attributes: the property list (safe_style_css) and each declaration (safecss_filter_attr_allow_css). The facade sets these as it loads.
|
Internals 2
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | css(string $style): string# | The style attribute's declarations kept as written, as the reference keeps them (probes kses, block-supports): a listed property, named exactly (the list through safe_style_css when the runtime hooks it; --* lets custom properties through), or a bare value; and nothing in the value that could end the declaration or open a function (\ ( & = } or a comment) once the functions it may use are taken out, with a background's gradients and the url()s of allowed schemes a background, a cursor, a filter, a mask or a clip path may use. Each is asked through safecss_filter_attr_allow_css. | |||
| private | cssTestString(string $declaration, array $allowed): ?string# | What of a declaration must hold no unsafe character: its value (or the bare value) without the functions it may use; null for a property not listed, or a url() with a scheme not allowed (on a property that cannot use one, its parenthesis fails the test).
|
Nothing matches.