From 83e0324d96e4ce8e385562caffdc1d60f5d6b154 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Sat, 20 Mar 2010 01:04:30 +1300 Subject: [PATCH] Provide a more useful error output on an XML parser failure. --- inc/CalDAVRequest.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/inc/CalDAVRequest.php b/inc/CalDAVRequest.php index 77792aba..d4dd4e22 100644 --- a/inc/CalDAVRequest.php +++ b/inc/CalDAVRequest.php @@ -501,7 +501,13 @@ EOSQL; $this->xml_tags = array(); xml_parser_set_option ( $xml_parser, XML_OPTION_SKIP_WHITE, 1 ); xml_parser_set_option ( $xml_parser, XML_OPTION_CASE_FOLDING, 0 ); - xml_parse_into_struct( $xml_parser, $this->raw_post, $this->xml_tags ); + $rc = xml_parse_into_struct( $xml_parser, $this->raw_post, $this->xml_tags ); + if ( $rc == false ) { + dbg_error_log( 'ERROR', 'XML parsing error: %s at line %d, column %d', + xml_error_string(xml_get_error_code($xml_parser)), + xml_get_current_line_number($xml_parser), xml_get_current_column_number($xml_parser) ); + $this->XMLResponse( 400, new XMLElement( 'error', new XMLElement('invalid-xml'), array( 'xmlns' => 'DAV:') ) ); + } xml_parser_free($xml_parser); if ( count($this->xml_tags) ) { dbg_error_log( "caldav", " Parsed incoming XML request body." );