Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(210)

Issue 10943044: Rewrite client side CSS sanitization code. (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 8 months ago by MikeSamuel
Modified:
12 years, 8 months ago
Reviewers:
felix8a
CC:
google-caja-discuss_googlegroups.com
Base URL:
http://google-caja.googlecode.com/svn/trunk/
Visibility:
Public.

Description

Prior 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. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+887 lines, -1585 lines) Patch
M src/com/google/caja/lang/css/CssPropBit.java View 1 2 3 4 5 6 7 1 chunk +15 lines, -4 lines 0 comments Download
M src/com/google/caja/lang/css/CssPropertyPatterns.java View 1 2 3 4 5 6 7 14 chunks +271 lines, -608 lines 0 comments Download
D src/com/google/caja/lang/css/JSRE.java View 1 2 3 4 5 6 7 1 chunk +0 lines, -595 lines 0 comments Download
M src/com/google/caja/parser/css/CssPropertySignature.java View 1 2 3 4 5 6 7 3 chunks +20 lines, -2 lines 0 comments Download
M src/com/google/caja/plugin/CssRewriter.java View 1 2 3 4 5 6 7 4 chunks +4 lines, -5 lines 0 comments Download
M src/com/google/caja/plugin/LinkStyleWhitelist.java View 1 2 3 4 5 6 7 4 chunks +6 lines, -5 lines 0 comments Download
M src/com/google/caja/plugin/domado.js View 1 2 3 4 5 6 7 3 chunks +7 lines, -9 lines 0 comments Download
M src/com/google/caja/plugin/html-sanitizer.js View 1 2 3 4 5 6 7 3 chunks +6 lines, -7 lines 0 comments Download
M src/com/google/caja/plugin/sanitizecss.js View 1 2 3 4 5 6 7 8 6 chunks +113 lines, -105 lines 0 comments Download
M src/com/google/caja/util/Bag.java View 1 2 3 4 5 6 7 1 chunk +2 lines, -0 lines 0 comments Download
M src/com/google/caja/util/Sets.java View 1 2 3 4 5 6 7 1 chunk +3 lines, -3 lines 0 comments Download
A src/com/google/caja/util/TypesafeSet.java View 1 2 3 4 5 1 chunk +72 lines, -0 lines 0 comments Download
M tests/com/google/caja/lang/css/CssPropertyPatternsTest.java View 1 2 3 4 5 6 7 2 chunks +341 lines, -92 lines 0 comments Download
D tests/com/google/caja/lang/css/JSRETest.java View 1 2 3 4 5 6 7 1 chunk +0 lines, -97 lines 0 comments Download
M tests/com/google/caja/plugin/es53-test-domado-dom-guest.html View 1 2 3 4 5 6 7 1 chunk +1 line, -27 lines 0 comments Download
M tests/com/google/caja/plugin/html-css-sanitizer-test.js View 1 2 3 4 5 6 7 2 chunks +4 lines, -3 lines 0 comments Download
M tests/com/google/caja/plugin/sanitizecss_test.js View 1 2 3 4 5 6 7 12 chunks +22 lines, -23 lines 0 comments Download

Messages

Total messages: 14
MikeSamuel
12 years, 8 months ago (2013-07-10 20:01:39 UTC) #1
MikeSamuel
Prior to this CL we turned CSS signatures into regular expressions. This code was tricky, ...
12 years, 8 months ago (2013-07-10 20:05:16 UTC) #2
MikeSamuel
Prior to this CL we turned CSS signatures into regular expressions. This code was tricky, ...
12 years, 8 months ago (2013-07-10 20:09:39 UTC) #3
MikeSamuel
Prior to this CL we turned CSS signatures into regular expressions. This code was tricky, ...
12 years, 8 months ago (2013-07-10 20:16:04 UTC) #4
felix8a
mostly looks fine so far https://codereview.appspot.com/10943044/diff/14001/src/com/google/caja/lang/css/CssPropertyPatterns.java File src/com/google/caja/lang/css/CssPropertyPatterns.java (right): https://codereview.appspot.com/10943044/diff/14001/src/com/google/caja/lang/css/CssPropertyPatterns.java#newcode199 src/com/google/caja/lang/css/CssPropertyPatterns.java:199: } else if (sig ...
12 years, 8 months ago (2013-07-11 22:33:36 UTC) #5
MikeSamuel
Prior to this CL we turned CSS signatures into regular expressions. This code was tricky, ...
12 years, 8 months ago (2013-07-12 04:56:17 UTC) #6
MikeSamuel
Prior to this CL we turned CSS signatures into regular expressions. This code was tricky, ...
12 years, 8 months ago (2013-07-12 19:36:15 UTC) #7
MikeSamuel
https://codereview.appspot.com/10943044/diff/14001/src/com/google/caja/lang/css/CssPropertyPatterns.java File src/com/google/caja/lang/css/CssPropertyPatterns.java (right): https://codereview.appspot.com/10943044/diff/14001/src/com/google/caja/lang/css/CssPropertyPatterns.java#newcode199 src/com/google/caja/lang/css/CssPropertyPatterns.java:199: } else if (sig instanceof CssPropertySignature.ProgIdSignature) { On 2013/07/11 ...
12 years, 8 months ago (2013-07-12 19:45:58 UTC) #8
felix8a
https://codereview.appspot.com/10943044/diff/14001/src/com/google/caja/plugin/CssRewriter.java File src/com/google/caja/plugin/CssRewriter.java (right): https://codereview.appspot.com/10943044/diff/14001/src/com/google/caja/plugin/CssRewriter.java#newcode429 src/com/google/caja/plugin/CssRewriter.java:429: if (!CSS21_COLOR_NAMES.contains(colorName.getCanonicalForm())) { On 2013/07/12 19:45:59, MikeSamuel wrote: > ...
12 years, 8 months ago (2013-07-12 19:47:29 UTC) #9
MikeSamuel
Prior to this CL we turned CSS signatures into regular expressions. This code was tricky, ...
12 years, 8 months ago (2013-07-12 19:58:24 UTC) #10
felix8a
lgtm https://codereview.appspot.com/10943044/diff/30001/src/com/google/caja/plugin/sanitizecss.js File src/com/google/caja/plugin/sanitizecss.js (right): https://codereview.appspot.com/10943044/diff/30001/src/com/google/caja/plugin/sanitizecss.js#newcode188 src/com/google/caja/plugin/sanitizecss.js:188: // to treate ['Arial', 'Black'] equivalently to ['"Arial ...
12 years, 8 months ago (2013-07-15 20:07:11 UTC) #11
MikeSamuel
Prior to this CL we turned CSS signatures into regular expressions. This code was tricky, ...
12 years, 8 months ago (2013-07-15 20:17:41 UTC) #12
MikeSamuel
Prior to this CL we turned CSS signatures into regular expressions. This code was tricky, ...
12 years, 8 months ago (2013-07-15 20:21:40 UTC) #13
MikeSamuel
12 years, 8 months ago (2013-07-15 20:21:59 UTC) #14
https://codereview.appspot.com/10943044/diff/30001/src/com/google/caja/plugin...
File src/com/google/caja/plugin/sanitizecss.js (right):

https://codereview.appspot.com/10943044/diff/30001/src/com/google/caja/plugin...
src/com/google/caja/plugin/sanitizecss.js:188: // to treate ['Arial', 'Black']
equivalently to ['"Arial Black"'].
On 2013/07/15 20:07:12, felix8a wrote:
> typo "treate"

Done.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b