You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2011/09/30 20:02:50 UTC

svn commit: r1177759 - /myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/context/PartialResponseWriterImpl.java

Author: lu4242
Date: Fri Sep 30 18:02:50 2011
New Revision: 1177759

URL: http://svn.apache.org/viewvc?rev=1177759&view=rev
Log:
MYFACES-3339 Ajax embedded CDATA Sequence lost on the server once an ajax refresh is triggered

Modified:
    myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/context/PartialResponseWriterImpl.java

Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/context/PartialResponseWriterImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/context/PartialResponseWriterImpl.java?rev=1177759&r1=1177758&r2=1177759&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/context/PartialResponseWriterImpl.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/context/PartialResponseWriterImpl.java Fri Sep 30 18:02:50 2011
@@ -196,6 +196,18 @@ public class PartialResponseWriterImpl e
         currentElement.getWriter().flush();
         StringBuffer buffer = currentElement.getDoubleBuffer().getBuffer();
 
+        int i = buffer.indexOf("]]>");
+        if (i >= 0)
+        {
+            do
+            {
+                buffer.replace(i, i+3, "]]><![CDATA[]]]]><![CDATA[>");
+                i=i+27; //27 is "]]><![CDATA[]]]]><![CDATA[>".length();
+            }
+            while ( (i = buffer.indexOf("]]>",i)) >= 0 );
+        }
+        return buffer.toString();
+        /*
         String resultString = buffer.toString();
         //section http://www.w3.org/TR/REC-xml/#sec-cdata-sect everything is parsed
         //until it hits a ]]> hence we need to do some mapping here
@@ -210,11 +222,15 @@ public class PartialResponseWriterImpl e
             //we now first remove pending javascript CDATA blocks
             //the reason is if we leave them the ppr chokes on them
             //the syntax from the auto generated CDATA usually is //\s+<![CDATA[
-            resultString = resultString.replaceAll("//\\s*((\\<\\!\\[CDATA\\[)|(\\]\\]\\>))", "");
+            // -= Leonardo Uribe =- Do this cause a bug on the client side, because
+            // scripts containing '&' will be considered invalid xml. 
+            //resultString = resultString.replaceAll("//\\s*((\\<\\!\\[CDATA\\[)|(\\]\\]\\>))", "");
+
             //now to fullfill the xml spec we have to replace all ]] with blocks of cdata
             resultString = resultString.replaceAll("\\]\\]\\>", "]]><![CDATA[]]]]><![CDATA[>");
         }
         return resultString;
+        */
     }
 
     //--- we need to override ppr specifics to cover the case