incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r612087 - /incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/parameters/ParameterSupport.java
Date Tue, 15 Jan 2008 11:34:37 GMT
Author: bdelacretaz
Date: Tue Jan 15 03:34:25 2008
New Revision: 612087

URL: http://svn.apache.org/viewvc?rev=612087&view=rev
Log:
SLING-152 - fix parsing of application/x-www-form-urlencoded parameters, using hardcoded default
encoding for now

Modified:
    incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/parameters/ParameterSupport.java

Modified: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/parameters/ParameterSupport.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/parameters/ParameterSupport.java?rev=612087&r1=612086&r2=612087&view=diff
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/parameters/ParameterSupport.java
(original)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/parameters/ParameterSupport.java
Tue Jan 15 03:34:25 2008
@@ -20,6 +20,7 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
 import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.List;
@@ -132,13 +133,21 @@
     }
 
     protected void parseFormEncodedPost(ParameterMap parameters) {
-        try {
-            Util.parse(this.getServletRequest().getInputStream(),
-                this.getServletRequest().getCharacterEncoding(), parameters, false);
-        } catch (IOException ioe) {
-            // TODO: log
-        } catch (Throwable t) {
-            // TODO: log
+        // TODO see SLING-152 - for now this is hardcoded to Util.ENCODING_DEFAULT
+        final Map<?, ?> pMap = this.getServletRequest().getParameterMap();
+        for (Map.Entry<?, ?> entry : pMap.entrySet()) {
+            final String name = (String)entry.getKey();
+            final String[] values = (String[]) entry.getValue();
+            for (int i = 0; i < values.length; i++) {
+                final EncodedRequestParameter rp = new EncodedRequestParameter(Util.ENCODING_DEFAULT);
+                try {
+                    rp.setContent(values[i].getBytes(Util.ENCODING_DEFAULT));
+                } catch(UnsupportedEncodingException ue) {
+                    throw new Error("Unexpected UnsupportedEncodingException for encoding="
+ Util.ENCODING_DEFAULT);
+                }
+                parameters.addParameter(name, rp);
+            }
+            
         }
     }
 



Mime
View raw message