Style Attribute Safety
These rules cover the style attribute. Other hardening is in Security and hardening.
- A string
style={:s}keeps only the declarations thatstyle=${s}keeps on the server's first paint. A declaration stays when it isname:valuewith no\, comment,expression(,javascript:,-moz-bindingorbehaviorin the value.scroll-behaviorstays in a value. Wisp also refuses a declaration whose name isbehavior,-moz-bindingor-ms-behavior, in any case.live.jsfilters thestyleattribute that the page sets: a string, an object, a quoted value with{:...}and a spread. It refuses the same names, and each declaration whose name has a\or a/*(a CSS escape or a comment). It reads each;as the end of a declaration, also inside a quote or inurl(). So it can refuse a part of a quoted value that looks like such a declaration. It keeps every other part as it is, also a data URL with a;in a quote. The server's first paint refuses a value with;, so it leaves such a data URL out. Aurl()stays on both. - The build fails for a hole in the name of a declaration in a quoted
styleattribute (style="-moz-${x}:v",style="${a}${b}:v",style="a:b;${c}"). Two values that pass the check one by one can write a banned name together. A hole aftername:stays. The error is:a ${} in a `style` attribute must come after `name:`. A property name must be text in the file. Write style="color:${value}" or style=${declarations}. The same holds for a<wisp:element>and a component tag.
Is This Page Useful?