Don't attempt to parse the input as XML unless an XML header was explicitly

sent.
This commit is contained in:
Andrew McMillan 2006-12-10 21:12:28 +13:00
parent bac02abded
commit 9904914d5a

View File

@ -148,13 +148,17 @@ class CalDAVRequest
if ( !isset($this->user_no) ) $this->user_no = $session->user_no; if ( !isset($this->user_no) ) $this->user_no = $session->user_no;
/** /**
* If the content we are receiving is XML then we parse it here. * If the content we are receiving is XML then we parse it here. RFC2518 says we
* should reasonably expect to see either text/xml or application/xml
*/ */
$xml_parser = xml_parser_create_ns('UTF-8'); dbg_log_array( "caldav", '_SERVER', $_SERVER, true );
$this->xml_tags = array(); if ( preg_match( '#(application|text)/xml#', $_SERVER['CONTENT_TYPE'] ) ) {
xml_parser_set_option ( $xml_parser, XML_OPTION_SKIP_WHITE, 1 ); $xml_parser = xml_parser_create_ns('UTF-8');
xml_parse_into_struct( $xml_parser, $this->raw_post, $this->xml_tags ); $this->xml_tags = array();
xml_parser_free($xml_parser); xml_parser_set_option ( $xml_parser, XML_OPTION_SKIP_WHITE, 1 );
xml_parse_into_struct( $xml_parser, $this->raw_post, $this->xml_tags );
xml_parser_free($xml_parser);
}
/** /**
* Look out for If-None-Match or If-Match headers * Look out for If-None-Match or If-Match headers