Revision: 5564
Author: [email protected]
Date: Mon Aug 19 22:29:55 2013 UTC
Log: es53 css sanitizer barfs on <global-name>
https://codereview.appspot.com/12837046
<style>p { animation-name: foo; }</style>
throws a SomethingWidgy error in es53.
That's very unfriendly, because the guest-code developer ends up
getting a "Server Error" message with no diagnostic details,
and it's not at all obvious what to do next to fix it.
Since css rules are loaded dynamically at run-time, we can't really
know at compile-time what all the rule atoms are, so encountering an
unrecognized atom doesn't really merit a SomethingWidgy error.
Instead, this CL just fails the match, which makes CSS validator
emit a warning about a bad value, drop the value, and proceed.
And the guest-code developer can find the warning easily.
R=mikesamuel
http://code.google.com/p/google-caja/source/detail?r=5564
Modified:
/trunk/src/com/google/caja/plugin/CssValidator.java
/trunk/tests/com/google/caja/plugin/CssValidatorTest.java
=======================================
--- /trunk/src/com/google/caja/plugin/CssValidator.java Tue Aug 13 00:53:18
2013 UTC
+++ /trunk/src/com/google/caja/plugin/CssValidator.java Mon Aug 19 22:29:55
2013 UTC
@@ -1339,9 +1339,13 @@
}
candidate.match(term, CssPropertyPartType.IDENT, propertyName);
++candidate.exprIdx;
+ } else if ("global-name".equals(symbolName)) {
+ // <global-name> is used by @keyframes and animation-name. Since es53
+ // doesn't support @keyframes, we just fail the match.
+ return false;
} else {
- throw new SomethingWidgyHappenedError(
- "unhandled symbol " + sig.symbolName + "\n" + dump(atom));
+ // Unrecognized atom: fail the match.
+ return false;
}
if (null != constraints
=======================================
--- /trunk/tests/com/google/caja/plugin/CssValidatorTest.java Tue Aug 13
00:53:18 2013 UTC
+++ /trunk/tests/com/google/caja/plugin/CssValidatorTest.java Mon Aug 19
22:29:55 2013 UTC
@@ -39,6 +39,18 @@
*/
public final class CssValidatorTest extends CajaTestCase {
+ public final void testGlobalName() throws Exception {
+ runTest("a { animation-name: foo; }",
+ "StyleSheet\n"
+ + " RuleSet\n"
+ + " Selector\n"
+ + " SimpleSelector\n"
+ + " IdentLiteral : a\n"
+ + " EmptyDeclaration\n",
+ "WARNING: css property animation-name has bad value: ==>foo<==");
+ }
+
+
public final void testVendorPrefix() throws Exception {
runTest("a { -moz-animation-duration: 1s }",
"StyleSheet\n"
--
---
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.