tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1002185 - in /tomcat/trunk: java/org/apache/catalina/servlets/CGIServlet.java webapps/docs/changelog.xml
Date Tue, 28 Sep 2010 14:43:03 GMT
Author: markt
Date: Tue Sep 28 14:43:03 2010
New Revision: 1002185

URL: http://svn.apache.org/viewvc?rev=1002185&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49657
Correctly handle CGI executables with spaces in the name/path

Modified:
    tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java?rev=1002185&r1=1002184&r2=1002185&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java (original)
+++ tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java Tue Sep 28 14:43:03 2010
@@ -1576,38 +1576,20 @@ public final class CGIServlet extends Ht
             Process proc = null;
             int bufRead = -1;
 
-            //create query arguments
-            StringBuilder cmdAndArgs = new StringBuilder();
-            if (command.indexOf(" ") < 0) {
-                cmdAndArgs.append(command);
-            } else {
-                // Spaces used as delimiter, so need to use quotes
-                cmdAndArgs.append("\"");
-                cmdAndArgs.append(command);
-                cmdAndArgs.append("\"");
-            }
+            String[] cmdAndArgs = new String[params.size() + 2];
+            
+            cmdAndArgs[0] = cgiExecutable;
+            
+            cmdAndArgs[1] = command;
 
+            //create query arguments
             for (int i=0; i < params.size(); i++) {
-                cmdAndArgs.append(" ");
-                String param = params.get(i);
-                if (param.indexOf(" ") < 0) {
-                    cmdAndArgs.append(param);
-                } else {
-                    // Spaces used as delimiter, so need to use quotes
-                    cmdAndArgs.append("\"");
-                    cmdAndArgs.append(param);
-                    cmdAndArgs.append("\"");
-                }
+                cmdAndArgs[i + 2] = params.get(i);
             }
 
-            StringBuilder command = new StringBuilder(cgiExecutable);
-            command.append(" ");
-            command.append(cmdAndArgs.toString());
-            cmdAndArgs = command;
-
             try {
                 rt = Runtime.getRuntime();
-                proc = rt.exec(cmdAndArgs.toString(), hashToStringArray(env), wd);
+                proc = rt.exec(cmdAndArgs, hashToStringArray(env), wd);
     
                 String sContentLength = env.get("CONTENT_LENGTH");
 

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1002185&r1=1002184&r2=1002185&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Tue Sep 28 14:43:03 2010
@@ -58,6 +58,10 @@
         Sylvain Laurent.
       </fix>
       <fix>
+        <bug>49657</bug>: Handle CGI executables with spaces in the path.
+        (markt)
+      </fix>
+      <fix>
         <bug>49670</bug>: Restore SSO functionality that was broken by Lifecycle
         refactoring. (markt)
       </fix>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message