You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by pq...@apache.org on 2008/12/05 08:15:22 UTC

svn commit: r723627 - in /httpd/httpd/branches/wombat-integration: include/util_script.h server/util_script.c

Author: pquerna
Date: Thu Dec  4 23:15:22 2008
New Revision: 723627

URL: http://svn.apache.org/viewvc?rev=723627&view=rev
Log:
Add new api, ap_args_to_table, to parse a request's arguments into a table.

Modified:
    httpd/httpd/branches/wombat-integration/include/util_script.h
    httpd/httpd/branches/wombat-integration/server/util_script.c

Modified: httpd/httpd/branches/wombat-integration/include/util_script.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/wombat-integration/include/util_script.h?rev=723627&r1=723626&r2=723627&view=diff
==============================================================================
--- httpd/httpd/branches/wombat-integration/include/util_script.h (original)
+++ httpd/httpd/branches/wombat-integration/include/util_script.h Thu Dec  4 23:15:22 2008
@@ -140,6 +140,8 @@
 				       int (*getsfunc) (char *, int, void *),
 				       void *getsfunc_data);
 
+AP_DECLARE(void) ap_args_to_table(request_rec *r, apr_table_t **table);
+
 #ifdef __cplusplus
 }
 #endif

Modified: httpd/httpd/branches/wombat-integration/server/util_script.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/wombat-integration/server/util_script.c?rev=723627&r1=723626&r2=723627&view=diff
==============================================================================
--- httpd/httpd/branches/wombat-integration/server/util_script.c (original)
+++ httpd/httpd/branches/wombat-integration/server/util_script.c Thu Dec  4 23:15:22 2008
@@ -721,3 +721,41 @@
     va_end(strs.args);
     return res;
 }
+
+
+static void
+argstr_to_table(apr_pool_t *p, char *str, apr_table_t *parms)
+{
+    char *key;
+    char *value;
+    char *strtok_state;
+    
+    key = apr_strtok(str, "&", &strtok_state);
+    while (key) {
+        value = strchr(key, '=');
+        if (value) {
+            *value = '\0';      /* Split the string in two */
+            value++;            /* Skip passed the = */
+        }
+        else {
+            value = "1";
+        }
+        ap_unescape_url(key);
+        ap_unescape_url(value);
+        apr_table_set(parms, key, value);
+        /*
+         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
+         "Found query arg: %s = %s", key, value);
+         */
+        key = apr_strtok(NULL, "&", &strtok_state);
+    }
+}
+
+AP_DECLARE(void) ap_args_to_table(request_rec *r, apr_table_t **table)
+{
+    apr_table_t *t = apr_table_make(r->pool, 10);
+    argstr_to_table(r->pool, r->args, t);
+    *table = t;
+}
+
+



Re: svn commit: r723627 - in /httpd/httpd/branches/wombat-integration: include/util_script.h server/util_script.c

Posted by Ruediger Pluem <rp...@apache.org>.

On 12/06/2008 09:46 AM, Ruediger Pluem wrote:
> 
> On 12/05/2008 08:15 AM, pquerna@apache.org wrote:
>> Author: pquerna
>> Date: Thu Dec  4 23:15:22 2008
>> New Revision: 723627
>>
>> URL: http://svn.apache.org/viewvc?rev=723627&view=rev
>> Log:
>> Add new api, ap_args_to_table, to parse a request's arguments into a table.
>>
>> Modified:
>>     httpd/httpd/branches/wombat-integration/include/util_script.h
>>     httpd/httpd/branches/wombat-integration/server/util_script.c
>>
>> Modified: httpd/httpd/branches/wombat-integration/include/util_script.h
>> URL: http://svn.apache.org/viewvc/httpd/httpd/branches/wombat-integration/include/util_script.h?rev=723627&r1=723626&r2=723627&view=diff
>> ==============================================================================
>> --- httpd/httpd/branches/wombat-integration/include/util_script.h (original)
>> +++ httpd/httpd/branches/wombat-integration/include/util_script.h Thu Dec  4 23:15:22 2008
>> @@ -140,6 +140,8 @@
>>  				       int (*getsfunc) (char *, int, void *),
>>  				       void *getsfunc_data);
>>  
>> +AP_DECLARE(void) ap_args_to_table(request_rec *r, apr_table_t **table);
>> +
> 
> Hm. This requires a minor bump.
> 
>>  #ifdef __cplusplus
>>  }
>>  #endif
>>
>> Modified: httpd/httpd/branches/wombat-integration/server/util_script.c
>> URL: http://svn.apache.org/viewvc/httpd/httpd/branches/wombat-integration/server/util_script.c?rev=723627&r1=723626&r2=723627&view=diff
>> ==============================================================================
>> --- httpd/httpd/branches/wombat-integration/server/util_script.c (original)
>> +++ httpd/httpd/branches/wombat-integration/server/util_script.c Thu Dec  4 23:15:22 2008
>> @@ -721,3 +721,41 @@
>>      va_end(strs.args);
>>      return res;
>>  }
>> +
>> +
>> +static void
>> +argstr_to_table(apr_pool_t *p, char *str, apr_table_t *parms)
>> +{
>> +    char *key;
>> +    char *value;
>> +    char *strtok_state;
>> +    
> 
> Hm, we should make a copy of str before changing it in the while lopp
> below.

Reading further on in the commits I changed my mind. We should not do
a copy here, but passing the pool as argument to the function seems to be pointless to me.

> 
>> +    key = apr_strtok(str, "&", &strtok_state);
>> +    while (key) {
>> +        value = strchr(key, '=');
>> +        if (value) {
>> +            *value = '\0';      /* Split the string in two */
>> +            value++;            /* Skip passed the = */
>> +        }
>> +        else {
>> +            value = "1";
>> +        }
>> +        ap_unescape_url(key);
>> +        ap_unescape_url(value);
>> +        apr_table_set(parms, key, value);
>> +        /*
>> +         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
> 
> r is no parameter for this function.
> 
>> +         "Found query arg: %s = %s", key, value);
>> +         */
>> +        key = apr_strtok(NULL, "&", &strtok_state);
>> +    }
>> +}
>> +
>> +AP_DECLARE(void) ap_args_to_table(request_rec *r, apr_table_t **table)
>> +{
>> +    apr_table_t *t = apr_table_make(r->pool, 10);
>> +    argstr_to_table(r->pool, r->args, t);

We should make a copy of r->args here before passing as argstr_to_table changes
the contents of the second parameter.


Regards

RĂ¼diger

Re: svn commit: r723627 - in /httpd/httpd/branches/wombat-integration: include/util_script.h server/util_script.c

Posted by Paul Querna <ch...@force-elite.com>.
Ruediger Pluem wrote:
> 
> On 12/05/2008 08:15 AM, pquerna@apache.org wrote:
>> Author: pquerna
>> Date: Thu Dec  4 23:15:22 2008
>> New Revision: 723627
>>
>> URL: http://svn.apache.org/viewvc?rev=723627&view=rev
>> Log:
>> Add new api, ap_args_to_table, to parse a request's arguments into a table.
.... 				       void *getsfunc_data);
>>  
>> +AP_DECLARE(void) ap_args_to_table(request_rec *r, apr_table_t **table);
>> +
> 
> Hm. This requires a minor bump.

Bumped r724083.

...
>> +static void
>> +argstr_to_table(apr_pool_t *p, char *str, apr_table_t *parms)
>> +{
>> +    char *key;
>> +    char *value;
>> +    char *strtok_state;
>> +    
> 
> Hm, we should make a copy of str before changing it in the while lopp
> below.

Yah, fixed in r724080.

>> +    key = apr_strtok(str, "&", &strtok_state);
>> +    while (key) {
>> +        value = strchr(key, '=');
>> +        if (value) {
>> +            *value = '\0';      /* Split the string in two */
>> +            value++;            /* Skip passed the = */
>> +        }
>> +        else {
>> +            value = "1";
>> +        }
>> +        ap_unescape_url(key);
>> +        ap_unescape_url(value);
>> +        apr_table_set(parms, key, value);
>> +        /*
>> +         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
> 
> r is no parameter for this function.
>

Removed this old commented out block in r724084.

Thanks,
Paul


Re: svn commit: r723627 - in /httpd/httpd/branches/wombat-integration: include/util_script.h server/util_script.c

Posted by Ruediger Pluem <rp...@apache.org>.

On 12/05/2008 08:15 AM, pquerna@apache.org wrote:
> Author: pquerna
> Date: Thu Dec  4 23:15:22 2008
> New Revision: 723627
> 
> URL: http://svn.apache.org/viewvc?rev=723627&view=rev
> Log:
> Add new api, ap_args_to_table, to parse a request's arguments into a table.
> 
> Modified:
>     httpd/httpd/branches/wombat-integration/include/util_script.h
>     httpd/httpd/branches/wombat-integration/server/util_script.c
> 
> Modified: httpd/httpd/branches/wombat-integration/include/util_script.h
> URL: http://svn.apache.org/viewvc/httpd/httpd/branches/wombat-integration/include/util_script.h?rev=723627&r1=723626&r2=723627&view=diff
> ==============================================================================
> --- httpd/httpd/branches/wombat-integration/include/util_script.h (original)
> +++ httpd/httpd/branches/wombat-integration/include/util_script.h Thu Dec  4 23:15:22 2008
> @@ -140,6 +140,8 @@
>  				       int (*getsfunc) (char *, int, void *),
>  				       void *getsfunc_data);
>  
> +AP_DECLARE(void) ap_args_to_table(request_rec *r, apr_table_t **table);
> +

Hm. This requires a minor bump.

>  #ifdef __cplusplus
>  }
>  #endif
> 
> Modified: httpd/httpd/branches/wombat-integration/server/util_script.c
> URL: http://svn.apache.org/viewvc/httpd/httpd/branches/wombat-integration/server/util_script.c?rev=723627&r1=723626&r2=723627&view=diff
> ==============================================================================
> --- httpd/httpd/branches/wombat-integration/server/util_script.c (original)
> +++ httpd/httpd/branches/wombat-integration/server/util_script.c Thu Dec  4 23:15:22 2008
> @@ -721,3 +721,41 @@
>      va_end(strs.args);
>      return res;
>  }
> +
> +
> +static void
> +argstr_to_table(apr_pool_t *p, char *str, apr_table_t *parms)
> +{
> +    char *key;
> +    char *value;
> +    char *strtok_state;
> +    

Hm, we should make a copy of str before changing it in the while lopp
below.

> +    key = apr_strtok(str, "&", &strtok_state);
> +    while (key) {
> +        value = strchr(key, '=');
> +        if (value) {
> +            *value = '\0';      /* Split the string in two */
> +            value++;            /* Skip passed the = */
> +        }
> +        else {
> +            value = "1";
> +        }
> +        ap_unescape_url(key);
> +        ap_unescape_url(value);
> +        apr_table_set(parms, key, value);
> +        /*
> +         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,

r is no parameter for this function.

> +         "Found query arg: %s = %s", key, value);
> +         */
> +        key = apr_strtok(NULL, "&", &strtok_state);
> +    }
> +}
> +
> +AP_DECLARE(void) ap_args_to_table(request_rec *r, apr_table_t **table)
> +{
> +    apr_table_t *t = apr_table_make(r->pool, 10);
> +    argstr_to_table(r->pool, r->args, t);
> +    *table = t;
> +}
> +
> +
> 
> 
>