manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1085506 - in /incubator/lcf/trunk: CHANGES.txt framework/agents/src/main/java/org/apache/manifoldcf/agents/common/XMLWriterContext.java
Date Fri, 25 Mar 2011 18:39:00 GMT
Author: kwright
Date: Fri Mar 25 18:39:00 2011
New Revision: 1085506

URL: http://svn.apache.org/viewvc?rev=1085506&view=rev
Log:
Fix for CONNECTORS-171.

Modified:
    incubator/lcf/trunk/CHANGES.txt
    incubator/lcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/common/XMLWriterContext.java

Modified: incubator/lcf/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/CHANGES.txt?rev=1085506&r1=1085505&r2=1085506&view=diff
==============================================================================
--- incubator/lcf/trunk/CHANGES.txt (original)
+++ incubator/lcf/trunk/CHANGES.txt Fri Mar 25 18:39:00 2011
@@ -3,6 +3,9 @@ $Id$
 
 ======================= 0.3-dev =========================
 
+CONNECTORS-171: Make sure XML output from within XML document does not
+corrupt entity references.
+(Fuad Efendi)
 
 ======================= Release 0.2 =======================
 Release Date:  See http://incubator.apache.org/connectors for the official release date.

Modified: incubator/lcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/common/XMLWriterContext.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/common/XMLWriterContext.java?rev=1085506&r1=1085505&r2=1085506&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/common/XMLWriterContext.java
(original)
+++ incubator/lcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/common/XMLWriterContext.java
Fri Mar 25 18:39:00 2011
@@ -76,7 +76,7 @@ public class XMLWriterContext extends XM
   {
     try
     {
-      theWriter.write(ch,start,length);
+      escapeCharData(ch,start,length,theWriter);
     }
     catch (java.net.SocketTimeoutException e)
     {
@@ -178,4 +178,20 @@ public class XMLWriterContext extends XM
     }
     return rval.toString();
   }
+  
+  /** Escapes sequence of characters to output writer */
+  protected static void escapeCharData(char [] chars, int start, int length, Writer out)
throws IOException
+  {
+    for (int i=start; i<length; i++) {
+      char x = chars[i];
+      if (x == '<' || x == '>' || x == '&'|| (x < ' ' && x >= 0))
+      {
+        StringBuffer rval = new StringBuffer();
+        rval.append("&#").append(Integer.toString((int)x)).append(";");
+        out.write(rval.toString());
+        continue;
+      }
+      out.write(x);
+    }
+  }
 }



Mime
View raw message