cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jer...@apache.org
Subject svn commit: r691610 - in /cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/http: HttpEnvironment.java HttpRequest.java
Date Wed, 03 Sep 2008 13:43:03 GMT
Author: jeremy
Date: Wed Sep  3 06:43:02 2008
New Revision: 691610

URL: http://svn.apache.org/viewvc?rev=691610&view=rev
Log:
changes to the way Cocoon handles request decoding, uses encoding info from the request if
available

Modified:
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/http/HttpEnvironment.java
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/http/HttpRequest.java

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/http/HttpEnvironment.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/http/HttpEnvironment.java?rev=691610&r1=691609&r2=691610&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/http/HttpEnvironment.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/http/HttpEnvironment.java
Wed Sep  3 06:43:02 2008
@@ -75,8 +75,14 @@
         super(uri, null, root, null);
 
         this.request = new HttpRequest(req, this);
-        this.request.setCharacterEncoding(defaultFormEncoding);
-        this.request.setContainerEncoding(containerEncoding);
+
+        if (req.getCharacterEncoding() == null) { // use the value from web.xml
+            this.request.setContainerEncoding(containerEncoding != null ? containerEncoding
: "ISO-8859-1");
+        } else { // use what we have been given
+            this.request.setContainerEncoding(req.getCharacterEncoding());
+        }
+        this.request.setCharacterEncoding(defaultFormEncoding != null ? defaultFormEncoding
: "UTF-8");
+        
         this.response = new HttpResponse(res);
         this.webcontext = context;
 

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/http/HttpRequest.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/http/HttpRequest.java?rev=691610&r1=691609&r2=691610&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/http/HttpRequest.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/http/HttpRequest.java
Wed Sep  3 06:43:02 2008
@@ -324,23 +324,17 @@
 
     public String getParameter(String name) {
         String value = this.req.getParameter(name);
-        if (this.form_encoding == null || this.container_encoding == null || value == null)
{
-            return value;
+        if (!this.container_encoding.equals(this.form_encoding)) {
+            value = decode(value);
         }
-        // Form and container encoding are equal, skip expensive value decoding
-        if (this.container_encoding.equals(this.form_encoding)) {
-            return value;
-        }
-        return decode(value);
+        return value;
     }
 
     private String decode(String str) {
         if (str == null) return null;
         try {
-            if (this.container_encoding == null)
-                this.container_encoding = "ISO-8859-1";
             byte[] bytes = str.getBytes(this.container_encoding);
-            return new String(bytes, form_encoding);
+            return new String(bytes, this.form_encoding);
         } catch (UnsupportedEncodingException uee) {
             throw new CascadingRuntimeException("Unsupported Encoding Exception", uee);
         }
@@ -353,7 +347,7 @@
     public String[] getParameterValues(String name) {
         String[] values = this.req.getParameterValues(name);
         if (values == null) return null;
-        if (this.form_encoding == null) {
+        if (this.container_encoding.equals(this.form_encoding)) {
             return values;
         }
         String[] decoded_values = new String[values.length];



Mime
View raw message