DescriptionPrior to this CL we turned CSS signatures into regular expressions.
This code was tricky, required shipping lots of (opaque and hard-to-debug) JS,
and the regular expressions blew up in size when functions (like rgb(...))
nest.
This changes our CSS sanitization to a simple token filtering, but with
functions treated as top-level entities.
Changes include
- Getting rid of JS regex generation and optimization code
- Revamping the CSS property bits to support unicode ranges, and make the
distinction between quoted strings, URLs, and unreserved-words more obvious.
- Add a cssFns property to the css-defs.js property value maps.
- Gets rid of the cssExtras property in the css-defs.js property value maps.
- Gets rid of z-index special cases.
- Reworks sanitize-css.js and clients to use the new format.
sanitizeCssProperty no longer takes a schema and just assumes cssSchema is
present in the same way sanitizeStylesheet does.
Metrics
I measured the size of the JS before and after.
Before After Relative
Generated JS 43.75 kB 22.31 kB 51%
Minified Bundle JS 89.42 kB 69.52 kB 78%
GZipped JS 4.74 kB 4.18 kB 88%
GZipped Bundle JS 19.51 kB 18.85 kB 97%
So the generated JS schema went from half of our sanitizer bundle to a
third, and should scale linearly with the size of our schema, and not
explode as we flesh out CSS3.
----
Submitted @ r5493
Patch Set 1 #Patch Set 2 : Rewrite client side CSS sanitization code. #Patch Set 3 : Rewrite client side CSS sanitization code. #Patch Set 4 : Rewrite client side CSS sanitization code. #
Total comments: 11
Patch Set 5 : Rewrite client side CSS sanitization code. #Patch Set 6 : Rewrite client side CSS sanitization code. #Patch Set 7 : Rewrite client side CSS sanitization code. #
Total comments: 2
Patch Set 8 : Rewrite client side CSS sanitization code. #Patch Set 9 : Rewrite client side CSS sanitization code. #MessagesTotal messages: 14
|