httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rede...@apache.org
Subject cvs commit: httpd-2.0/modules/experimental mod_ext_filter.c
Date Wed, 21 Aug 2002 16:42:54 GMT
rederpj     2002/08/21 09:42:54

  Modified:    .        CHANGES
               modules/experimental mod_ext_filter.c
  Log:
  Submitted by: Paul J. Reder
  Reviewed by: Jeff Trawick
  
  Fixes required to get quoted and escaped command args working in
  mod_ext_filter. There are also fixes in APR that were submitted
  via a patch to apr_cpystrn.c PR 11793
  
  Revision  Changes    Path
  1.892     +3 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.891
  retrieving revision 1.892
  diff -u -r1.891 -r1.892
  --- CHANGES	21 Aug 2002 16:01:14 -0000	1.891
  +++ CHANGES	21 Aug 2002 16:42:53 -0000	1.892
  @@ -1,4 +1,7 @@
   Changes with Apache 2.0.41
  +  *) Fixes required to get quoted and escaped command args working in
  +     mod_ext_filter. PR 11793 [Paul J. Reder]
  +
     *) mod-proxy: handle proxied responses with no status lines
        [JD Silvester <jsilves@uwo.ca>, Brett Huttley <brett@huttley.net>]
   
  
  
  
  1.37      +22 -16    httpd-2.0/modules/experimental/mod_ext_filter.c
  
  Index: mod_ext_filter.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_ext_filter.c,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- mod_ext_filter.c	1 Aug 2002 23:26:43 -0000	1.36
  +++ mod_ext_filter.c	21 Aug 2002 16:42:54 -0000	1.37
  @@ -88,8 +88,7 @@
       const char *command;
       const char *enable_env;
       const char *disable_env;
  -    int numArgs;
  -    char *args[30];
  +    char **args;
       const char *intype;             /* list of IMTs we process (well, just one for now)
*/
   #define INTYPE_ALL (char *)1
       const char *outtype;            /* IMT of filtered output */
  @@ -193,38 +192,45 @@
       if (**args == '"') {
           const char *start = *args + 1;
           char *parms;
  +        int escaping = 0;
  +        apr_status_t rv;
   
           ++*args; /* move past leading " */
  -        while (**args && **args != '"') {
  +        /* find true end of args string (accounting for escaped quotes) */
  +        while (**args && (**args != '"' || (**args == '"' && escaping)))
{
  +            if (escaping) {
  +                escaping = 0;
  +            }
  +            else if (**args == '\\') {
  +                escaping = 1;
  +            }
               ++*args;
           }
           if (**args != '"') {
               return "Expected cmd= delimiter";
           }
  +        /* copy *just* the arg string for parsing, */
           parms = apr_pstrndup(p, start, *args - start);
           ++*args; /* move past trailing " */
   
  -        /* parms now has the command-line to parse */
  -        while (filter->numArgs < 30 &&
  -               strlen(filter->args[filter->numArgs] = ap_getword_white_nc(p, &parms)))
{
  -            ++filter->numArgs;
  -        }
  -        if (filter->numArgs < 1) {
  +        /* parse and tokenize the args. */
  +        rv = apr_tokenize_to_argv(parms, &(filter->args), p);
  +        if (rv != APR_SUCCESS) {
               return "cmd= parse error";
           }
  -        filter->args[filter->numArgs] = NULL; /* we stored "" in the while() loop
*/
  -        filter->command = filter->args[0];
       }
       else
       {
           /* simple path */
  +        /* Allocate space for one argv pointer and parse the args. */
  +        filter->args = (char **)apr_palloc(p, sizeof(char *));
           filter->args[0] = ap_getword_white(p, args);
  -        if (!filter->args[0]) {
  -            return "Invalid cmd= parameter";
  -        }
  -        filter->numArgs = 1;
  -        filter->command = filter->args[0];
       }
  +    if (!filter->args[0]) {
  +        return "Invalid cmd= parameter";
  +    }
  +    filter->command = filter->args[0];
  +    
       return NULL;
   }
   
  
  
  

Mime
View raw message