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:47:34 UTC
svn commit: r1365535 - in /myfaces/tobago/branches/tobago-1.5.x: ./
tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Style.java
tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java
Author: lofwyr
Date: Wed Jul 25 11:47:34 2012
New Revision: 1365535
URL: http://svn.apache.org/viewvc?rev=1365535&view=rev
Log:
TOBAGO-1186: Styles should be escaped, when the contains strings
Merged from trunk [from revision 1365525]
Modified:
myfaces/tobago/branches/tobago-1.5.x/ (props changed)
myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Style.java
myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java
Propchange: myfaces/tobago/branches/tobago-1.5.x/
------------------------------------------------------------------------------
Merged /myfaces/tobago/trunk:r1365525
Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Style.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Style.java?rev=1365535&r1=1365534&r2=1365535&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Style.java (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Style.java Wed Jul 25 11:47:34 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/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java?rev=1365535&r1=1365534&r2=1365535&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java Wed Jul 25 11:47:34 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());
+ }
}
}