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

[PATCH] formatting dav human-readable errors

From: Philip Martin <philip_at_codematters.co.uk>
Date: 2004-09-27 23:47:52 CEST

When mod_dav_svn generates a m:human-readable error it gets sent via
Apache's mod_dav function dav_error_response_tag() like this:

        ap_rprintf(r,
                   "<m:human-readable errcode=\"%d\">" DEBUG_CR
                   "%s" DEBUG_CR
                   "</m:human-readable>" DEBUG_CR,
                   err->error_id,
                   apr_xml_quote_string(r->pool, err->desc, 0));

and DEBUG_CR is defined in Apache's mod_dav.h like so:

     #if 1
     ...
     #define DEBUG_CR "\n"
     ...
     #else
     ...
     #define DEBUG_CR ""
     ...
     #endif

The result is that the error sent to the client has additional
leading and trailing newlines, and when the client prints the error it
looks like

svn:
The version resource does not correspond to the resource within the transaction. Either the requested version resource is out of date (needs to be updated), or the requested version resource is newer than the transaction root (restart the commit).

I find it easier to parse if the leading newline is removed to give

svn: The version resource ...

Does anyone object to this:

* subversion/libsvn_ra_dav/util.c (end_err_element): Strip a leading
  and trailing newline from ELEM_human_readable cdata.

Index: subversion/libsvn_ra_dav/util.c
===================================================================
--- subversion/libsvn_ra_dav/util.c (revision 11132)
+++ subversion/libsvn_ra_dav/util.c (working copy)
@@ -399,7 +399,18 @@
     case ELEM_human_readable:
       {
         if (cdata && *err)
- (*err)->message = apr_pstrdup((*err)->pool, cdata);
+ {
+ /* dav_error_response_tag() on the server will add a leading
+ and trailing newline if DEBUG_CR is defined in mod_dav.h */
+ 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);
+ }
         break;
       }
 

-- 
Philip Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Sep 27 23:48:10 2004

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.