httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: apache-1.3/src/main util.c
Date Thu, 21 Mar 2002 16:01:31 GMT
wrowe       02/03/21 08:01:31

  Modified:    src      ApacheCore.def
               src/include httpd.h
               src/main util.c
  Log:
    Share ap_double_quotes() code between OS2 and Win32 to use
    for Win32's command.com, and introduce ap_caret_escape_args()
    for Win32's cmd.exe.  [William Rowe]
  
  Revision  Changes    Path
  1.31      +2 -0      apache-1.3/src/ApacheCore.def
  
  Index: ApacheCore.def
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/ApacheCore.def,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- ApacheCore.def	20 Jan 2002 22:45:14 -0000	1.30
  +++ ApacheCore.def	21 Mar 2002 16:01:31 -0000	1.31
  @@ -442,3 +442,5 @@
           ap_update_child_status @434
           ap_sendwithtimeout @435
           ap_recvwithtimeout @436
  +        ap_caret_escape_args @437
  +        ap_double_quotes @438
  
  
  
  1.355     +5 -1      apache-1.3/src/include/httpd.h
  
  Index: httpd.h
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/include/httpd.h,v
  retrieving revision 1.354
  retrieving revision 1.355
  diff -u -r1.354 -r1.355
  --- httpd.h	13 Mar 2002 21:05:29 -0000	1.354
  +++ httpd.h	21 Mar 2002 16:01:31 -0000	1.355
  @@ -1051,9 +1051,13 @@
   API_EXPORT(char *) ap_uudecode(pool *p, const char *bufcoded);
   API_EXPORT(char *) ap_uuencode(pool *p, char *string); 
   
  +#if defined(OS2) || defined(WIN32)
  +API_EXPORT(char *) ap_double_quotes(pool *p, const char *str);
  +API_EXPORT(char *) ap_caret_escape_args(pool *p, const char *str);
  +#endif
  +
   #ifdef OS2
   void os2pathname(char *path);
  -char *ap_double_quotes(pool *p, char *str);
   #endif
   
   API_EXPORT(int)    ap_regexec(const regex_t *preg, const char *string,
  
  
  
  1.203     +73 -30    apache-1.3/src/main/util.c
  
  Index: util.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/main/util.c,v
  retrieving revision 1.202
  retrieving revision 1.203
  diff -u -r1.202 -r1.203
  --- util.c	21 Mar 2002 06:00:34 -0000	1.202
  +++ util.c	21 Mar 2002 16:01:31 -0000	1.203
  @@ -1457,10 +1457,13 @@
       s = (const unsigned char *)str;
       for (; *s; ++s) {
   
  -#if defined(OS2) || defined(WIN32) || defined(NETWARE)
  -	/* Don't allow '&' in parameters under OS/2. */
  -	/* This can be used to send commands to the shell. */
  -	if (*s == '&') {
  +#if defined(WIN32) || defined(OS2)
  +        /* 
  +         * Newlines to Win32/OS2 CreateProcess() are ill advised.
  +         * Convert them to spaces since they are effectively white
  +         * space to most applications
  +         */
  +	if (*s == '\r' || *s == '\n') {
   	    *d++ = ' ';
   	    continue;
   	}
  @@ -2113,6 +2116,72 @@
       return ap_pbase64encode(p, string);
   }
   
  +#if defined(OS2) || defined(WIN32)
  +/* quotes in the string are doubled up.
  + * Used to escape quotes in args passed to OS/2's cmd.exe
  + * and Win32's command.com
  + */
  +API_EXPORT(char *) ap_double_quotes(pool *p, const char *str)
  +{
  +    int num_quotes = 0;
  +    int len = 0;
  +    char *quote_doubled_str, *dest;
  +    
  +    while (str[len]) {
  +        if (str[len++] == '\"') {
  +            num_quotes++;
  +        }
  +    }
  +    
  +    quote_doubled_str = ap_palloc(p, len + num_quotes + 1);
  +    dest = quote_doubled_str;
  +    
  +    while (*str) {
  +        if (*str == '\"')
  +            *(dest++) = '\"';
  +        *(dest++) = *(str++);
  +    }
  +    
  +    *dest = 0;
  +    return quote_doubled_str;
  +}
  +
  +/*
  + * If ap_caret_escape_args resembles ap_escape_shell_cmd, it aught to.
  + * Taken verbatim so we can trust the integrety of this function.
  + */
  +API_EXPORT(char *) ap_caret_escape_args(pool *p, const char *str)
  +{
  +    char *cmd;
  +    unsigned char *d;
  +    const unsigned char *s;
  +
  +    cmd = ap_palloc(p, 2 * strlen(str) + 1);	/* Be safe */
  +    d = (unsigned char *)cmd;
  +    s = (const unsigned char *)str;
  +    for (; *s; ++s) {
  +
  +        /* 
  +         * Newlines to Win32/OS2 CreateProcess() are ill advised.
  +         * Convert them to spaces since they are effectively white
  +         * space to most applications
  +         */
  +	if (*s == '\r' || *s == '\n') {
  +	    *d++ = ' ';
  +            continue;
  +	}
  +
  +	if (TEST_CHAR(*s, T_ESCAPE_SHELL_CMD)) {
  +	    *d++ = '^';
  +	}
  +	*d++ = *s;
  +    }
  +    *d = '\0';
  +
  +    return cmd;
  +}
  +#endif
  +
   #ifdef OS2
   void os2pathname(char *path)
   {
  @@ -2138,32 +2207,6 @@
   
       strcpy(path, newpath);
   };
  -
  -/* quotes in the string are doubled up.
  - * Used to escape quotes in args passed to OS/2's cmd.exe
  - */
  -char *ap_double_quotes(pool *p, char *str)
  -{
  -    int num_quotes = 0;
  -    int len = 0;
  -    char *quote_doubled_str, *dest;
  -    
  -    while (str[len]) {
  -        num_quotes += str[len++] == '\"';
  -    }
  -    
  -    quote_doubled_str = ap_palloc(p, len + num_quotes + 1);
  -    dest = quote_doubled_str;
  -    
  -    while (*str) {
  -        if (*str == '\"')
  -            *(dest++) = '\"';
  -        *(dest++) = *(str++);
  -    }
  -    
  -    *dest = 0;
  -    return quote_doubled_str;
  -}
   #endif
   
   
  
  
  

Mime
View raw message