You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2012/07/25 13:35:50 UTC
svn commit: r1365525 - in
/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago:
renderkit/css/Style.java webapp/TobagoResponseWriter.java
Author: lofwyr
Date: Wed Jul 25 11:35:49 2012
New Revision: 1365525
URL: http://svn.apache.org/viewvc?rev=1365525&view=rev
Log:
TOBAGO-1186: Styles should be escaped, when the contains strings
Modified:
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Style.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Style.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Style.java?rev=1365525&r1=1365524&r2=1365525&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Style.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Style.java Wed Jul 25 11:35:49 2012
@@ -128,6 +128,15 @@ public class Style implements Serializab
}
}
+ /**
+ * Checks if the encode string holds free text, which must be escaped.
+ * This is the case for image URLs.
+ * For {@link Measure}, and enum types like {@link Display} no escaping is needed.
+ */
+ public boolean needsToBeEscaped() {
+ return backgroundImage != null;
+ }
+
public String encode() {
StringBuilder buf = new StringBuilder();
if (width != null) {
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java?rev=1365525&r1=1365524&r2=1365525&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java Wed Jul 25 11:35:49 2012
@@ -170,7 +170,10 @@ public abstract class TobagoResponseWrit
*/
public void writeStyleAttribute(Style style) throws IOException {
if (style != null) {
- writeAttribute(HtmlAttributes.STYLE, style.encode(), false);
+ final String value = style.encode();
+ if (value != null) {
+ writeAttribute(HtmlAttributes.STYLE, value, style.needsToBeEscaped());
+ }
}
}