stoddard    98/08/05 16:07:55

  Modified:    src/main util_script.c
  Log:
  Fix PR2495 (Win32): quote script filenames to handle white space
  
  Revision  Changes    Path
  1.124     +9 -6      apache-1.3/src/main/util_script.c
  
  Index: util_script.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/main/util_script.c,v
  retrieving revision 1.123
  retrieving revision 1.124
  diff -u -r1.123 -r1.124
  --- util_script.c     1998/08/03 09:15:00     1.123
  +++ util_script.c     1998/08/05 23:07:54     1.124
  @@ -779,6 +779,7 @@
        int i, sz;
        char *dot;
        char *exename;
  +        char *quoted_filename;
        int is_exe = 0;
        STARTUPINFO si;
        PROCESS_INFORMATION pi;
  @@ -792,6 +793,8 @@
        interpreter[0] = 0;
        pid = -1;
   
  +        quoted_filename = ap_pstrcat(r->pool, "\"", r->filename, "\"", NULL);
  +
        exename = strrchr(r->filename, '/');
        if (!exename) {
            exename = strrchr(r->filename, '\\');
  @@ -877,7 +880,7 @@
                 * When the CGI is a straight binary executable, 
                 * we can run it as is
                 */
  -             pCommand = r->filename;
  +             pCommand = quoted_filename;
            }
            else if (is_script) {
                   /* When an interpreter is needed, we need to create 
  @@ -885,14 +888,14 @@
                    * followed by the CGI script name.  
                 */
                pCommand = ap_pstrcat(r->pool, interpreter + 2, " ", 
  -                                   r->filename, NULL);
  +                                   quoted_filename, NULL);
            }
            else {
                /* If not an executable or script, just execute it
                    * from a command prompt.  
                    */
                pCommand = ap_pstrcat(r->pool, SHELL_PATH, " /C ", 
  -                                   r->filename, NULL);
  +                                   quoted_filename, NULL);
            }
        }
        else {
  @@ -938,16 +941,16 @@
             * so now build the command line.
             */
            if (is_exe || is_binary) {
  -             pCommand = ap_pstrcat(r->pool, r->filename, " ", 
  +             pCommand = ap_pstrcat(r->pool, quoted_filename, " ", 
                                      arguments, NULL);
            }
            else if (is_script) {
                pCommand = ap_pstrcat(r->pool, interpreter + 2, " ", 
  -                                   r->filename, " ", arguments, NULL);
  +                                   quoted_filename, " ", arguments, NULL);
            }
            else {
                pCommand = ap_pstrcat(r->pool, SHELL_PATH, " /C ", 
  -                                   r->filename, " ", arguments, NULL);
  +                                   quoted_filename, " ", arguments, NULL);
            }
        }
     
  
  
  

Reply via email to