cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: r606391 - /cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/postable/components/ServletServiceSerializer.java
Date Sat, 22 Dec 2007 04:18:34 GMT
Author: vgritsenko
Date: Fri Dec 21 20:18:34 2007
New Revision: 606391

URL: http://svn.apache.org/viewvc?rev=606391&view=rev
Log:
ServletServiceSerializer was copying unicode (see /catalog and /i18n samples) character data
into output stream using platform encoding (ISO-8859-1), and crashing hard after that (duh!).
Quick fix - convert data into UTF-8.

Modified:
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/postable/components/ServletServiceSerializer.java

Modified: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/postable/components/ServletServiceSerializer.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/postable/components/ServletServiceSerializer.java?rev=606391&r1=606390&r2=606391&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/postable/components/ServletServiceSerializer.java
(original)
+++ cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/postable/components/ServletServiceSerializer.java
Fri Dec 21 20:18:34 2007
@@ -17,7 +17,9 @@
 package org.apache.cocoon.servletservice.postable.components;
 
 import java.io.IOException;
+import java.io.OutputStreamWriter;
 import java.io.StringReader;
+import java.io.Writer;
 import java.util.Map;
 
 import org.apache.avalon.framework.parameters.ParameterException;
@@ -101,12 +103,19 @@
 		} catch (ProcessingException e) {
 			throw new SAXException("Exception occured while serializing content of sax buffer", e);
 		}
-		try {
-			IOUtils.copy(new StringReader(serializedXML), servletSource.getOutputStream());
-		} catch (IOException e) {
+
+        try {
+            // TODO Improve this quick fix; it is better for Postable to provide Writer instead.
+            // TODO Need to specify 
+            // Convert output stream to writer to specify UTF-8 encoding.
+            Writer out = new OutputStreamWriter(servletSource.getOutputStream(), "UTF-8");
+            IOUtils.copy(new StringReader(serializedXML), out);
+            out.flush();
+        } catch (IOException e) {
 			throw new SAXException("Exception occured while writing to the output stream of source
'" + servletSource.getURI() + "'", e);
-		}
-		try {
+        }
+
+        try {
 			//here real mime type is set, see Spring bean's configuration comment
 			response.setHeader("Content-Type", servletSource.getMimeType());
 			



Mime
View raw message