[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r1241050 - /subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c

From: Daniel Shahaf <danielsh_at_elego.de>
Date: Mon, 6 Feb 2012 17:59:04 +0200

This still strips whitespace around ='s in the value:
    SVNHooksEnv "name = x = y"
will result in
    setenv("name", "x=y", 1)
whereas I believe it should result in
    setenv("name", "x = y", 1)
(and, to be honest, I'd be happy with
    setenv("name ", " x = y", 1)
as well).

WDYT? How should it behave?

stsp_at_apache.org wrote on Mon, Feb 06, 2012 at 15:46:54 -0000:
> Author: stsp
> Date: Mon Feb 6 15:46:54 2012
> New Revision: 1241050
>
> URL: http://svn.apache.org/viewvc?rev=1241050&view=rev
> Log:
> * subversion/mod_dav_svn/mod_dav_svn.c
> (SVNHooksEnv_cmd): Handle environment variables with values containing '='.
> While here, dup strings referenced from the hash table into the hash
> table's pool for safety.
>
> Modified:
> subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c
>
> Modified: subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c?rev=1241050&r1=1241049&r2=1241050&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c (original)
> +++ subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c Mon Feb 6 15:46:54 2012
> @@ -538,14 +538,36 @@ SVNHooksEnv_cmd(cmd_parms *cmd, void *co
> apr_array_header_t *var;
>
> var = svn_cstring_split(arg1, "=", TRUE, cmd->pool);
> - if (var && var->nelts == 2)
> + if (var && var->nelts >= 2)
> {
> dir_conf_t *conf = config;
> + const char *name;
> + const char *val;
>
> - apr_hash_set(conf->hooks_env,
> - APR_ARRAY_IDX(var, 0, const char *),
> - APR_HASH_KEY_STRING,
> - APR_ARRAY_IDX(var, 1, const char *));
> + name = apr_pstrdup(apr_hash_pool_get(conf->hooks_env),
> + APR_ARRAY_IDX(var, 0, const char *));
> +
> + /* Special case for values which contain '='. */
> + if (var->nelts > 2)
> + {
> + svn_stringbuf_t *buf;
> + int i;
> +
> + buf = svn_stringbuf_create(APR_ARRAY_IDX(var, 1, const char *),
> + cmd->pool);
> + for (i = 2; i < var->nelts; i++)
> + {
> + svn_stringbuf_appendbyte(buf, '=');
> + svn_stringbuf_appendcstr(buf, APR_ARRAY_IDX(var, i, const char *));
> + }
> +
> + val = apr_pstrdup(apr_hash_pool_get(conf->hooks_env), buf->data);
> + }
> + else
> + val = apr_pstrdup(apr_hash_pool_get(conf->hooks_env),
> + APR_ARRAY_IDX(var, 1, const char *));
> +
> + apr_hash_set(conf->hooks_env, name, APR_HASH_KEY_STRING, val);
> }
>
> return NULL;
>
>
Received on 2012-02-06 17:00:00 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.