Wisp is in pre-release, self-hosted since GitHub suspended us. Install it, or see the changelog.

Wisp

Style Attribute Safety

These rules cover the style attribute. Other hardening is in Security and hardening.

  • A string style={:s} keeps only the declarations that style=${s} keeps on the server's first paint. A declaration stays when it is name:value with no \, comment, expression(, javascript:, -moz-binding or behavior in the value. scroll-behavior stays in a value. Wisp also refuses a declaration whose name is behavior, -moz-binding or -ms-behavior, in any case. live.js filters the style attribute 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 in url(). 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. A url() stays on both.
  • The build fails for a hole in the name of a declaration in a quoted style attribute (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 after name: 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?

View This Page's Source

Type to search every docs page and heading.