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 2013/11/18 11:04:14 UTC

svn commit: r1542964 - in /myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago: internal/util/HtmlWriterUtils.java internal/webapp/TobagoResponseWriterBase.java webapp/TobagoResponseWriter.java

Author: lofwyr
Date: Mon Nov 18 10:04:14 2013
New Revision: 1542964

URL: http://svn.apache.org/r1542964
Log:
TOBAGO-1346: JSON friendly HTML code (change " with ' for attributes)

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/HtmlWriterUtils.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/webapp/TobagoResponseWriterBase.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/internal/util/HtmlWriterUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/HtmlWriterUtils.java?rev=1542964&r1=1542963&r2=1542964&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/HtmlWriterUtils.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/HtmlWriterUtils.java Mon Nov 18 10:04:14 2013
@@ -38,7 +38,7 @@ public final class HtmlWriterUtils exten
     CHARS_TO_ESCAPE['\n'] = "
".toCharArray(); // Line feed
     CHARS_TO_ESCAPE['\r'] = "
".toCharArray(); // Carriage return
 
-    CHARS_TO_ESCAPE['"'] = """.toCharArray();
+    CHARS_TO_ESCAPE['\''] = "'".toCharArray();
     CHARS_TO_ESCAPE['&'] = "&".toCharArray();
     CHARS_TO_ESCAPE['<'] = "&lt;".toCharArray();
     CHARS_TO_ESCAPE['>'] = "&gt;".toCharArray();

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/webapp/TobagoResponseWriterBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/webapp/TobagoResponseWriterBase.java?rev=1542964&r1=1542963&r2=1542964&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/webapp/TobagoResponseWriterBase.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/webapp/TobagoResponseWriterBase.java Mon Nov 18 10:04:14 2013
@@ -318,9 +318,9 @@ public abstract class TobagoResponseWrit
     if (value != null) {
       writer.write(' ');
       writer.write(name);
-      writer.write("=\"");
+      writer.write("='");
       writerAttributeValue(value, escape);
-      writer.write('\"');
+      writer.write('\'');
     }
   }
   protected abstract void writerAttributeValue(String value, boolean escape) throws IOException;

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=1542964&r1=1542963&r2=1542964&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 Mon Nov 18 10:04:14 2013
@@ -149,14 +149,13 @@ public abstract class TobagoResponseWrit
   public abstract void writeClassAttribute() throws IOException;
 
   /**
-   * Write the style attribute. The value will not escaped.
+   * Write the style attribute. The value may be escaped (depending of the content).
    */
   public void writeStyleAttribute(final Style style) throws IOException {
     if (style != null) {
       final String json = style.encodeJson();
       if (json.length() > 2) { // empty "{}" needs not to be written
-        writeAttribute(DataAttributes.STYLE, json, true);
-        // todo: check not escaping, when it's not needed, use: style.needsToBeEscaped()
+        writeAttribute(DataAttributes.STYLE, json, style.needsToBeEscaped());
       }
     }
   }