Reviewers: skybrian, mdempsky, xtof, tbroyer,

Description:
Adding convenience methods to SafeStylesUtils and SafeStylesBuilder for
style properties supported by Style.  For most properies, the name is
defined in SafeStylesUtils, and the value comes from an enum in Style or
a primitive type, so we know that the combination of the name and value
produces a string that satisfies the constraints of SafeStyles.

For properties that take open ended strings, such as "background-image"
and "color", the method is prefixed with "Trusted" and JavaDoc'd,
putting the burden on the user to ensure that the value is a trusted
value.  For example, SafeStylesUtils#forTrustedColor() and
SafeStylesBuilder#appendTrustedColor().  It would be very difficult to
guarentee that a string is safe. Unlike HTML where you can escape the
brackets, style attribute XSS vulnerabilities are subtle, especially in
older versions of IE where the "expression()" CSS value can execute
arbitrary javascript. So, instead of trying to provide a sanitizing
method, its up to the user to ensure the string is safe.  Also added the
methods fromTrustedNameAndValue(), which are escape hatches for create a
SafeStyles from any trusted name and value pair.

The generic methods in SafeStyles are prefixes with "from", as in
fromTrustedNameAndValue/fromTrustedString.  The property specific
methods are prefixed with "for", as in forPaddingTop/forZIndex. There
isn't some underlying reason for this, it just sounded better to me.


Please review this at http://gwt-code-reviews.appspot.com/1454808/

Affected files:
  M user/src/com/google/gwt/safecss/SafeCss.gwt.xml
  M user/src/com/google/gwt/safecss/shared/SafeStylesBuilder.java
  M user/src/com/google/gwt/safecss/shared/SafeStylesUtils.java
  M user/test/com/google/gwt/safecss/SafeCssGwtSuite.java
  M user/test/com/google/gwt/safecss/SafeCssJreSuite.java
  A user/test/com/google/gwt/safecss/shared/GwtSafeStylesUtilsTest.java
  M user/test/com/google/gwt/safecss/shared/SafeStylesStringTest.java
  A user/test/com/google/gwt/safecss/shared/SafeStylesUtilsTest.java


--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to