tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amy...@apache.org
Subject cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/servlets CGIServlet.java
Date Tue, 02 Sep 2003 22:44:32 GMT
amyroh      2003/09/02 15:44:32

  Modified:    catalina/src/share/org/apache/catalina/servlets
                        CGIServlet.java
  Log:
  Apply patch for bug 22857 and bug 22858 submitted by Mark Thomas <medthomas@ntlworld.com>
and fix obvious indentation errors.
  
  Revision  Changes    Path
  1.7       +23 -21    jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/servlets/CGIServlet.java
  
  Index: CGIServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/servlets/CGIServlet.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- CGIServlet.java	2 Sep 2003 21:22:05 -0000	1.6
  +++ CGIServlet.java	2 Sep 2003 22:44:32 -0000	1.7
  @@ -357,7 +357,7 @@
           //Wrapper wrapper = (Wrapper) getServletConfig();
           //context = (Context) wrapper.getParent();
   
  -    context = config.getServletContext();
  +        context = config.getServletContext();
           if (debug >= 1) {
               //log("init: Associated with Context '" + context.getPath() + "'");
           }
  @@ -429,10 +429,10 @@
           out.println("<li><b>contextPath</b> = " +
                          req.getContextPath());
           Cookie cookies[] = req.getCookies();
  -    if (cookies!=null) {
  -        for (int i = 0; i < cookies.length; i++)
  +        if (cookies!=null) {
  +            for (int i = 0; i < cookies.length; i++)
                   out.println("<li><b>cookie</b> " + cookies[i].getName()
+" = " +cookies[i].getValue());
  -    }
  +        }
           Enumeration headers = req.getHeaderNames();
           while (headers.hasMoreElements()) {
               String header = (String) headers.nextElement();
  @@ -567,8 +567,6 @@
           out.println("</ul>");
           out.println("<hr>");
   
  -
  -
       }
   
   
  @@ -743,7 +741,7 @@
            *
            */
           protected CGIEnvironment(HttpServletRequest req,
  -                                 ServletContext context) {
  +                                 ServletContext context) throws IOException {
               setupFromContext(context);
               setupFromRequest(req);
   
  @@ -939,7 +937,7 @@
            * @return   true if environment was set OK, false if there
            *           was a problem and no environment was set
            */
  -        protected boolean setCGIEnvironment(HttpServletRequest req) {
  +        protected boolean setCGIEnvironment(HttpServletRequest req) throws IOException
{
   
               /*
                * This method is slightly ugly; c'est la vie.
  @@ -1092,8 +1090,8 @@
                       //NOOP per CGI specification section 11.2
                   } else if("HOST".equalsIgnoreCase(header)) {
                       String host = req.getHeader(header);
  -        int idx =  host.indexOf(":");
  -        if(idx < 0) idx = host.length();
  +                    int idx =  host.indexOf(":");
  +                    if(idx < 0) idx = host.length();
                       envp.put("HTTP_" + header.replace('-', '_'),
                                host.substring(0, idx));
                   } else {
  @@ -1102,7 +1100,9 @@
                   }
               }
   
  -            command = sCGIFullPath;
  +            File fCGIFullPath = new File(sCGIFullPath);
  +            command = fCGIFullPath.getCanonicalPath();
  +
               envp.put("X_TOMCAT_SCRIPT_PATH", command);  //for kicks
   
               this.env = envp;
  @@ -1543,17 +1543,19 @@
   
               //create query arguments
               Enumeration paramNames = params.keys();
  -            StringBuffer cmdAndArgs = new StringBuffer(command);
  +            StringBuffer cmdAndArgs = new StringBuffer("\"" + command + "\"");
               if (paramNames != null && paramNames.hasMoreElements()) {
                   cmdAndArgs.append(" ");
                   while (paramNames.hasMoreElements()) {
                       String k = (String) paramNames.nextElement();
                       String v = params.get(k).toString();
                       if ((k.indexOf("=") < 0) && (v.indexOf("=") < 0)) {
  +                        cmdAndArgs.append("\"");
                           cmdAndArgs.append(k);
                           cmdAndArgs.append("=");
                           v = java.net.URLEncoder.encode(v);
                           cmdAndArgs.append(v);
  +                        cmdAndArgs.append("\"");
                           cmdAndArgs.append(" ");
                       }
                   }
  @@ -1566,11 +1568,11 @@
                   env.put("CONTENT_LENGTH", new Integer(contentLength));
               }*/
   
  -        if (command.endsWith(".pl") || command.endsWith(".cgi")) {
  +        //if (command.endsWith(".pl") || command.endsWith(".cgi")) {
               StringBuffer perlCommand = new StringBuffer("perl ");
               perlCommand.append(cmdAndArgs.toString());
               cmdAndArgs = perlCommand;
  -        }
  +        //}
   
               rt = Runtime.getRuntime();
               proc = rt.exec(cmdAndArgs.toString(), hashToStringArray(env), wd);
  
  
  

Mime
View raw message