Reviewers: kpreid2,
Description:
linear-gradient() works but -webkit-linear-gradient() gets dropped.
this CL fixes that for the client-side css sanitizer.
fixing it in the server-side css sanitizer is a little harder
(because the leading '-' is parsed as a separate token),
so I've just marked a TODO and I'm deferring that for now.
Please review this at https://codereview.appspot.com/12761044/
Affected files:
M src/com/google/caja/plugin/sanitizecss.js
M tests/com/google/caja/plugin/CssRewriterTest.java
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 5567)
+++ src/com/google/caja/plugin/sanitizecss.js (working copy)
@@ -189,12 +189,13 @@
// so allowing resumption at the next ';'.
if (!parenDepth) {
var fnToken = tokens[start].toLowerCase();
+ var bareFnToken = withoutVendorPrefix(fnToken);
// Cut out the originals, so the caller can step by one token.
var fnTokens = tokens.splice(start, end - start, '');
var fns = propertySchema.cssFns;
// Look for a function that matches the name.
for (var i = 0, nFns = fns.length; i < nFns; ++i) {
- if (fns[i].substring(0, fnToken.length) == fnToken) {
+ if (fns[i].substring(0, bareFnToken.length) == bareFnToken) {
fnTokens[0] = fnTokens[fnTokens.length - 1] = '';
// Recurse and sanitize the function parameters.
sanitize(
Index: tests/com/google/caja/plugin/CssRewriterTest.java
===================================================================
--- tests/com/google/caja/plugin/CssRewriterTest.java (revision 5567)
+++ tests/com/google/caja/plugin/CssRewriterTest.java (working copy)
@@ -197,6 +197,14 @@
pre + "background-image: linear-gradient(45deg, blue, red)\n}");
assertNoErrors();
+ // TODO(felix8a): -vendor-func() doesn't work yet
+ /*
+ runTest(
+ "p { background-image: -webkit-linear-gradient(1deg, blue, red)
}",
+ pre + "background-image: -webkit-linear-gradient(1deg, blue,
red)\n}");
+ assertNoErrors();
+ */
+
// A gradient going from the bottom right to the top left starting
blue and
// finishing red
runTest(
Index: tests/com/google/caja/plugin/sanitizecss_test.js
===================================================================
--- tests/com/google/caja/plugin/sanitizecss_test.js (revision 5567)
+++ tests/com/google/caja/plugin/sanitizecss_test.js (working copy)
@@ -327,6 +327,9 @@
var source = 'linear-gradient(to bottom right, red, rgb(255,0,0))';
var expect = 'linear-gradient(to bottom right , red , rgb(255 , 0 , 0))';
assertProperty('background-image', source, expect);
+ source = '-webkit-' + source;
+ expect = '-webkit-' + expect;
+ assertProperty('background-image', source, expect);
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.