You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Joe Orton <jo...@manyfish.co.uk> on 2004/10/12 22:27:31 UTC
Re: svn commit: r11340 - trunk/subversion/libsvn_ra_dav
On Tue, Oct 12, 2004 at 04:05:24PM -0500, Philip Martin wrote:
> --- trunk/subversion/libsvn_ra_dav/util.c (original)
> +++ trunk/subversion/libsvn_ra_dav/util.c Tue Oct 12 16:05:23 2004
> @@ -399,7 +399,19 @@
> case ELEM_human_readable:
> {
> if (cdata && *err)
> - (*err)->message = apr_pstrdup((*err)->pool, cdata);
> + {
> + /* On the server dav_error_response_tag() will add a leading
> + and trailing newline if DEBUG_CR is defined in mod_dav.h,
> + so remove any such characters here. */
> + apr_size_t len;
> + if (*cdata == '\n')
> + ++cdata;
> + len = strlen(cdata);
> + if (cdata[len-1] == '\n')
> + --len;
> +
> + (*err)->message = apr_pstrmemdup((*err)->pool, cdata, len);
Isn't this going to do nasty things if cdata is "\n" or "" on entry?
neon has ne_shave to make this kind of code simple, I'd just do:
message = apr_pstrdup((*err)->pool, ne_shave(cdata, " \r\n\t")).
joe
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: svn commit: r11340 - trunk/subversion/libsvn_ra_dav
Posted by Philip Martin <ph...@codematters.co.uk>.
Joe Orton <jo...@manyfish.co.uk> writes:
> On Tue, Oct 12, 2004 at 04:05:24PM -0500, Philip Martin wrote:
>> --- trunk/subversion/libsvn_ra_dav/util.c (original)
>> +++ trunk/subversion/libsvn_ra_dav/util.c Tue Oct 12 16:05:23 2004
>> @@ -399,7 +399,19 @@
>> case ELEM_human_readable:
>> {
>> if (cdata && *err)
>> - (*err)->message = apr_pstrdup((*err)->pool, cdata);
>> + {
>> + /* On the server dav_error_response_tag() will add a leading
>> + and trailing newline if DEBUG_CR is defined in mod_dav.h,
>> + so remove any such characters here. */
>> + apr_size_t len;
>> + if (*cdata == '\n')
>> + ++cdata;
>> + len = strlen(cdata);
>> + if (cdata[len-1] == '\n')
Oops! This should do
if (len > 0 && cdata[len-1] == '\n')
>> + --len;
>> +
>> + (*err)->message = apr_pstrmemdup((*err)->pool, cdata, len);
>
> Isn't this going to do nasty things if cdata is "\n" or "" on entry?
>
> neon has ne_shave to make this kind of code simple, I'd just do:
>
> message = apr_pstrdup((*err)->pool, ne_shave(cdata, " \r\n\t")).
I'm not trying to strip general whitespace, just a leading/trailing \n
on the basis that they are most likely to have been added by mod_dav.
--
Philip Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org