Author: rhuijben
Date: Tue Jul  2 09:16:55 2013
New Revision: 1498851

URL: http://svn.apache.org/r1498851
Log:
In the serf transition based xml parser: provide an explicit error if the root
element isn't matched in the transition table.

Without this most parsers just return success for every invalid element such
as '<html>' when the file contains valid xml.

This requires a better (new) error code which I'll add as a separate commit, to
allow backporting this.

* subversion/libsvn_ra_serf/xml.c
  (svn_ra_serf__xml_cb_start): Expect transitions from the default state to
    succeed, by returning an error when it doesn't.

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=1498851&r1=1498850&r2=1498851&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/xml.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/xml.c Tue Jul  2 09:16:55 2013
@@ -615,6 +615,14 @@ svn_ra_serf__xml_cb_start(svn_ra_serf__x
     }
   if (scan->ns == NULL)
     {
+      if (current->state == 0)
+        {
+          return svn_error_createf(
+                        SVN_ERR_RA_DAV_MALFORMED_DATA, NULL,
+                        _("XML Parsing failed: Unexpected root element '%s'"),
+                        elemname.name);
+        }
+
       xmlctx->waiting = elemname;
       /* ### return?  */
       return SVN_NO_ERROR;


Reply via email to