You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2014/01/16 11:35:32 UTC
svn commit: r1558745 - /subversion/trunk/subversion/libsvn_ra_serf/xml.c
Author: rhuijben
Date: Thu Jan 16 10:35:32 2014
New Revision: 1558745
URL: http://svn.apache.org/r1558745
Log:
Hide the informational 'Malformed XML: parsing aborted' errors in ra serf,
when we have a better error message in the error chain.
(See authz_tests.py 25 "remove a subdir with authz file" as an example
of a simplified error chain)
This resolves a slight regression against 1.8 where we ignored all xml
errors when we had an error in the chain.
* subversion/libsvn_ra_serf/xml.c
(EXPAT_HAS_STOPPARSER): Remove macro.
(parse_xml): Update argument to expat context. Handle the inner error here
instead of in the caller to allow hiding our abort handling.
(expat_start,
expat_end,
expat_cdata): Update abort call.
(expat_response_handler): Update caller.
Modified:
subversion/trunk/subversion/libsvn_ra_serf/xml.c
Modified: subversion/trunk/subversion/libsvn_ra_serf/xml.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/xml.c?rev=1558745&r1=1558744&r2=1558745&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/xml.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/xml.c Thu Jan 16 10:35:32 2014
@@ -59,10 +59,6 @@
(patch) <= XML_MICRO_VERSION))
#endif /* APR_VERSION_AT_LEAST */
-#if XML_VERSION_AT_LEAST(1, 95, 8)
-#define EXPAT_HAS_STOPPARSER
-#endif
-
/* Read/write chunks of this size into the spillbuf. */
#define PARSE_CHUNK_SIZE 8000
@@ -849,23 +845,34 @@ xml_cb_cdata(svn_ra_serf__xml_context_t
/* svn_error_t * wrapper around XML_Parse */
static APR_INLINE svn_error_t *
-parse_xml(XML_Parser parser, const char *data, apr_size_t len, svn_boolean_t is_final)
+parse_xml(struct expat_ctx_t *ectx, const char *data, apr_size_t len, svn_boolean_t is_final)
{
- int xml_status = XML_Parse(parser, data, (int)len, is_final);
+ int xml_status = XML_Parse(ectx->parser, data, (int)len, is_final);
const char *msg;
+ int xml_code;
- /* ### Perhaps we should filter some specific error codes on systems
- that use STOPPARSER to hide addtional errors */
if (xml_status == XML_STATUS_OK)
- return SVN_NO_ERROR;
+ return ectx->inner_error;
+
+ xml_code = XML_GetErrorCode(ectx->parser);
+
+#if XML_VERSION_AT_LEAST(1, 95, 8)
+ /* If we called XML_StopParser() expat will return an abort error. If we
+ have a better error stored we should ignore it as it will not help
+ the end-user to store it in the error chain. */
+ if (xml_code == XML_ERROR_ABORTED && ectx->inner_error)
+ return ectx->inner_error;
+#endif
- msg = XML_ErrorString(XML_GetErrorCode(parser));
+ msg = XML_ErrorString(xml_code);
- return svn_error_create(SVN_ERR_RA_DAV_MALFORMED_DATA,
- svn_error_createf(SVN_ERR_XML_MALFORMED, NULL,
- _("Malformed XML: %s"),
- msg),
- _("The XML response contains invalid XML"));
+ return svn_error_compose_create(
+ ectx->inner_error,
+ svn_error_create(SVN_ERR_RA_DAV_MALFORMED_DATA,
+ svn_error_createf(SVN_ERR_XML_MALFORMED, NULL,
+ _("Malformed XML: %s"),
+ msg),
+ _("The XML response contains invalid XML")));
}
/* Apr pool cleanup handler to release an XML_Parser in success and error
@@ -896,7 +903,7 @@ expat_start(void *userData, const char *
ectx->inner_error = svn_error_trace(xml_cb_start(ectx->xmlctx,
raw_name, attrs));
-#ifdef EXPAT_HAS_STOPPARSER
+#if XML_VERSION_AT_LEAST(1, 95, 8)
if (ectx->inner_error)
(void) XML_StopParser(ectx->parser, 0 /* resumable */);
#endif
@@ -914,7 +921,7 @@ expat_end(void *userData, const char *ra
ectx->inner_error = svn_error_trace(xml_cb_end(ectx->xmlctx, raw_name));
-#ifdef EXPAT_HAS_STOPPARSER
+#if XML_VERSION_AT_LEAST(1, 95, 8)
if (ectx->inner_error)
(void) XML_StopParser(ectx->parser, 0 /* resumable */);
#endif
@@ -932,7 +939,7 @@ expat_cdata(void *userData, const char *
ectx->inner_error = svn_error_trace(xml_cb_cdata(ectx->xmlctx, data, len));
-#ifdef EXPAT_HAS_STOPPARSER
+#if XML_VERSION_AT_LEAST(1, 95, 8)
if (ectx->inner_error)
(void) XML_StopParser(ectx->parser, 0 /* resumable */);
#endif
@@ -1008,9 +1015,7 @@ expat_response_handler(serf_request_t *r
else if (APR_STATUS_IS_EOF(status))
at_eof = TRUE;
- err = parse_xml(ectx->parser, data, len, at_eof /* isFinal */);
-
- err = svn_error_compose_create(ectx->inner_error, err);
+ err = parse_xml(ectx, data, len, at_eof /* isFinal */);
if (at_eof || err)
{