From: Paul J. Reder Date: Wed, 21 Aug 2002 16:42:54 +0000 (+0000) Subject: Submitted by: Paul J. Reder X-Git-Tag: AGB_BEFORE_AAA_CHANGES~200 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7b07efcfa70ea061eb82670e46e7ec0754059ef3;p=apache 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 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@96472 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index b50045ac6a..b05eb449e0 100644 --- a/CHANGES +++ b/CHANGES @@ -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 , Brett Huttley ] diff --git a/modules/experimental/mod_ext_filter.c b/modules/experimental/mod_ext_filter.c index fb7bc5fb73..31c773672d 100644 --- a/modules/experimental/mod_ext_filter.c +++ b/modules/experimental/mod_ext_filter.c @@ -88,8 +88,7 @@ typedef struct ef_filter_t { 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 @@ static const char *parse_cmd(apr_pool_t *p, const char **args, ef_filter_t *filt 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; }