Reviewers: kpreid2,

Description:
The javascript css sanitizer doesn't allow multiple pseudo-selectors,
for no particular reason. This fixes it.

This fixes issue 1873
https://code.google.com/p/google-caja/issues/detail?id=1873

Please review this at https://codereview.appspot.com/30570043/

Affected files (+11, -3 lines):
  M     src/com/google/caja/plugin/sanitizecss.js
  M     tests/com/google/caja/plugin/csslexer-test.js
  M     tests/com/google/caja/plugin/sanitizecss_test.js


Index: src/com/google/caja/plugin/sanitizecss.js
===================================================================
--- src/com/google/caja/plugin/sanitizecss.js   (revision 5635)
+++ src/com/google/caja/plugin/sanitizecss.js   (working copy)
@@ -637,12 +637,12 @@
                 valid = false;
               }
               historySensitive = true;
-              pseudoSelector = ':' + tok;
+              pseudoSelector += ':' + tok;
               element = 'a';
             } else if (
               HISTORY_NON_SENSITIVE_PSEUDO_SELECTOR_WHITELIST.test(tok)) {
-              historySensitive = false;
-              pseudoSelector = ':' + tok;
+              historySensitive = historySensitive || false;
+              pseudoSelector += ':' + tok;
             } else {
               break;
             }
Index: tests/com/google/caja/plugin/csslexer-test.js
===================================================================
--- tests/com/google/caja/plugin/csslexer-test.js       (revision 5635)
+++ tests/com/google/caja/plugin/csslexer-test.js       (working copy)
@@ -966,6 +966,13 @@
   jsunit.pass();
 });

+jsunitRegister('testLex60', function testLex59() {
+  assertLexedCss(
+    'a:hover:focus',
+    'a', ':', 'hover', ':', 'focus');
+  jsunit.pass();
+});
+
 jsunitRegister('testIssue1804', function testIssue1804() {
   assertLexedCss(',',  ',');
   assertLexedCss('a,', 'a', ',');
Index: tests/com/google/caja/plugin/sanitizecss_test.js
===================================================================
--- tests/com/google/caja/plugin/sanitizecss_test.js    (revision 5635)
+++ tests/com/google/caja/plugin/sanitizecss_test.js    (working copy)
@@ -287,6 +287,7 @@
     "#foo:first-letter", "sfx", [[".sfx #foo-sfx:first-letter"], []]);
   assertSelector("#foo:focus", "sfx", [[".sfx #foo-sfx:focus"], []]);
   assertSelector("#foo:hover", "sfx", [[".sfx #foo-sfx:hover"], []]);
+ assertSelector("#x:hover:focus", "sfx", [[".sfx #x-sfx:hover:focus"], []]);
   assertSelector("#foo:bogus", "sfx", [[], []]);
   jsunit.pass();
 });


--

--- You received this message because you are subscribed to the Google Groups "Google Caja Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to