Port fix bug 41008. Enable POST to be used with indexed queries. Patch provided by...
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 24 Nov 2006 23:58:18 +0000 (23:58 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 24 Nov 2006 23:58:18 +0000 (23:58 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@479052 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/servlets/CGIServlet.java
webapps/docs/changelog.xml

index 8190005..c37d99a 100644 (file)
@@ -794,30 +794,22 @@ public final class CGIServlet extends HttpServlet {
                 this.pathInfo = this.servletPath;
             }
             
-            // If request is HEAD or GET and Query String does not contain
-            // an unencoded "=" this is an indexed query. Parsed Query String
-            // forms command line parameters for cgi command.
-            if (!"GET".equals(req.getMethod()) &&
-                    !"HEAD".equals(req.getMethod()))
-                return;
-            
-            String qs = req.getQueryString();
-            
-            if (qs == null || qs.indexOf("=")>0)
-                return;
-            
-            int delimIndex = 0;
-            int lastDelimIndex = 0;
-            delimIndex = qs.indexOf("+");
-            
-            while (delimIndex >0) {
-                cmdLineParameters.add(URLDecoder.decode(qs.substring(
-                        lastDelimIndex,delimIndex),parameterEncoding));
-                lastDelimIndex = delimIndex + 1;
-                delimIndex = qs.indexOf("+",lastDelimIndex);
+            // If the request method is GET, POST or HEAD and the query string
+            // does not contain an unencoded "=" this is an indexed query.
+            // The parsed query string becomes the command line parameters
+            // for the cgi command.
+            if (req.getMethod().equals("GET")
+                || req.getMethod().equals("POST")
+                || req.getMethod().equals("HEAD")) {
+                String qs = req.getQueryString();
+                if (qs != null && qs.indexOf("=") == -1) {
+                    StringTokenizer qsTokens = new StringTokenizer(qs, "+");
+                    while ( qsTokens.hasMoreTokens() ) {
+                        cmdLineParameters.add(URLDecoder.decode(qsTokens.nextToken(),
+                                              parameterEncoding));
+                    }
+                }
             }
-            cmdLineParameters.add(URLDecoder.decode(qs.substring(
-                    lastDelimIndex),parameterEncoding));
         }
 
 
index 18acb49..eb59227 100644 (file)
         <bug>40929</bug>: Correct JavaDoc for StandardClassLoader. (markt)
       </fix>
       <fix>
+        <bug>41008</bug>: Allow POST to be used for indexed queries with CGI
+        Servlet. Patch provided by Chris Halstead. (markt)
+      </fix>
+      <fix>
         Fix usage of print on the servlet output stream if the processor never used
         a writer (fhanik)
       </fix>