chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r912159 - /incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-browser/src/main/java/org/apache/opencmis/browser/BrowseServlet.java
Date Sat, 20 Feb 2010 17:44:25 GMT
Author: fmui
Date: Sat Feb 20 17:44:25 2010
New Revision: 912159

URL: http://svn.apache.org/viewvc?rev=912159&view=rev
Log:
- fixed a bug in browser servlet: parameter values can have whitespaces

Modified:
    incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-browser/src/main/java/org/apache/opencmis/browser/BrowseServlet.java

Modified: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-browser/src/main/java/org/apache/opencmis/browser/BrowseServlet.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-browser/src/main/java/org/apache/opencmis/browser/BrowseServlet.java?rev=912159&r1=912158&r2=912159&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-browser/src/main/java/org/apache/opencmis/browser/BrowseServlet.java
(original)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-browser/src/main/java/org/apache/opencmis/browser/BrowseServlet.java
Sat Feb 20 17:44:25 2010
@@ -26,6 +26,7 @@
 import java.io.PrintWriter;
 import java.net.HttpURLConnection;
 import java.net.URL;
+import java.net.URLEncoder;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
@@ -154,6 +155,31 @@
       return;
     }
 
+    // re-encode parameters
+    int qm = browseUrl.indexOf('?');
+    if ((qm > -1) && (browseUrl.length() > qm + 1)) {
+      StringBuilder urlSb = new StringBuilder(browseUrl.substring(0, qm + 1));
+      StringBuilder paramSb = new StringBuilder();
+
+      for (int i = qm + 1; i < browseUrl.length(); i++) {
+        char c = browseUrl.charAt(i);
+        if ((c == '=') || (c == '&')) {
+          urlSb.append(URLEncoder.encode(paramSb.toString(), "UTF-8"));
+          urlSb.append(c);
+          paramSb = new StringBuilder();
+        }
+        else {
+          paramSb.append(c);
+        }
+      }
+
+      if (paramSb.length() > 0) {
+        urlSb.append(URLEncoder.encode(paramSb.toString(), "UTF-8"));
+      }
+
+      browseUrl = urlSb.toString();
+    }
+
     try {
       // get content
       URL url = new URL(browseUrl);



Mime
View raw message