Revision: 5636
Author: [email protected]
Date: Fri Nov 22 00:01:57 2013 UTC
Log: allow multiple css pseudo-selectors
https://codereview.appspot.com/30570043
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
R=kpreid2
http://code.google.com/p/google-caja/source/detail?r=5636
Modified:
/trunk/src/com/google/caja/plugin/sanitizecss.js
/trunk/tests/com/google/caja/plugin/csslexer-test.js
/trunk/tests/com/google/caja/plugin/sanitizecss_test.js
=======================================
--- /trunk/src/com/google/caja/plugin/sanitizecss.js Wed Sep 18 20:40:53
2013 UTC
+++ /trunk/src/com/google/caja/plugin/sanitizecss.js Fri Nov 22 00:01:57
2013 UTC
@@ -637,12 +637,11 @@
valid = false;
}
historySensitive = true;
- pseudoSelector = ':' + tok;
+ pseudoSelector += ':' + tok;
element = 'a';
} else if (
- HISTORY_NON_SENSITIVE_PSEUDO_SELECTOR_WHITELIST.test(tok)) {
- historySensitive = false;
- pseudoSelector = ':' + tok;
+ HISTORY_NON_SENSITIVE_PSEUDO_SELECTOR_WHITELIST.test(tok))
{
+ pseudoSelector += ':' + tok;
} else {
break;
}
=======================================
--- /trunk/tests/com/google/caja/plugin/csslexer-test.js Wed Jul 24
18:20:09 2013 UTC
+++ /trunk/tests/com/google/caja/plugin/csslexer-test.js Fri Nov 22
00:01:57 2013 UTC
@@ -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', ',');
=======================================
--- /trunk/tests/com/google/caja/plugin/sanitizecss_test.js Wed Aug 28
18:22:02 2013 UTC
+++ /trunk/tests/com/google/caja/plugin/sanitizecss_test.js Fri Nov 22
00:01:57 2013 UTC
@@ -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.