geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r800705 - in /geronimo/server/trunk/plugins/console/console-filter/src/main/java/org/apache/geronimo/console/filter: FilterResponseWrapper.java XSRFHandler.java
Date Tue, 04 Aug 2009 08:58:17 GMT
Author: xuhaihong
Date: Tue Aug  4 08:58:16 2009
New Revision: 800705

URL: http://svn.apache.org/viewvc?rev=800705&view=rev
Log:
GERONIMO-4758 The Server Console page displays messy codes when set zh as the prefered language
in browser(Patch from Siqi Du)

Modified:
    geronimo/server/trunk/plugins/console/console-filter/src/main/java/org/apache/geronimo/console/filter/FilterResponseWrapper.java
    geronimo/server/trunk/plugins/console/console-filter/src/main/java/org/apache/geronimo/console/filter/XSRFHandler.java

Modified: geronimo/server/trunk/plugins/console/console-filter/src/main/java/org/apache/geronimo/console/filter/FilterResponseWrapper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-filter/src/main/java/org/apache/geronimo/console/filter/FilterResponseWrapper.java?rev=800705&r1=800704&r2=800705&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/console/console-filter/src/main/java/org/apache/geronimo/console/filter/FilterResponseWrapper.java
(original)
+++ geronimo/server/trunk/plugins/console/console-filter/src/main/java/org/apache/geronimo/console/filter/FilterResponseWrapper.java
Tue Aug  4 08:58:16 2009
@@ -16,16 +16,22 @@
  */
 package org.apache.geronimo.console.filter;
 
+import java.io.BufferedWriter;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
 
 import javax.servlet.ServletOutputStream;
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponseWrapper;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * Implementation of a HttpServletResponseWrapper to allow us to edit the
  * response content from the filter chain/servlet before committing it to
@@ -34,6 +40,7 @@
  * @version $Rev$ $Date$
  */
 public final class FilterResponseWrapper extends HttpServletResponseWrapper {
+	private static final Logger log = LoggerFactory.getLogger(FilterResponseWrapper.class);
     private ByteArrayOutputStream output = null;
     private ResponseOutputStream stream = null;
     private PrintWriter writer = null;
@@ -168,7 +175,13 @@
         }
         this.output = new ByteArrayOutputStream();
         this.stream = new ResponseOutputStream(output);
-        this.writer = new PrintWriter(stream);
+        try{
+        	this.writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream,
"UTF-8")));
+        }
+        catch (UnsupportedEncodingException uee) {
+            // should never happen
+            log.error("new OutputStreamWriter(stream, UTF-8) failed.", uee);
+        }
     }
 
     /* (non-Javadoc)

Modified: geronimo/server/trunk/plugins/console/console-filter/src/main/java/org/apache/geronimo/console/filter/XSRFHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-filter/src/main/java/org/apache/geronimo/console/filter/XSRFHandler.java?rev=800705&r1=800704&r2=800705&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/console/console-filter/src/main/java/org/apache/geronimo/console/filter/XSRFHandler.java
(original)
+++ geronimo/server/trunk/plugins/console/console-filter/src/main/java/org/apache/geronimo/console/filter/XSRFHandler.java
Tue Aug  4 08:58:16 2009
@@ -217,7 +217,7 @@
                 // only update the content if it is HTML
                 if (cType.toLowerCase().indexOf("html") != -1) {
                     // get the response content
-                    String content = new String(hres.getOutput());
+                    String content = new String(hres.getOutput(), "UTF-8");
                     // update the JavaScript with the uniqueId for this session
                     updatedXsrfJS = xsrfJS.replace(XSRF_JS_UNIQUEID, uniqueId);
                     // update the response to contain the JS fragment



Mime
View raw message