You are here

function xmlrpc_message_parse in xmlrpc 8

Parses an XML-RPC message.

If parsing fails, the faultCode and faultString will be added to the message object.

Parameters

object $xmlrpc_message: An object generated by xmlrpc_message().

Return value

bool TRUE if parsing succeeded; FALSE otherwise.

3 calls to xmlrpc_message_parse()
XmlRpcBasicTest::testInvalidMessageParsing in src/Tests/XmlRpcBasicTest.php
Ensure that XML-RPC correctly handles invalid messages when parsing.
xmlrpc_server in ./xmlrpc.server.inc
Invokes XML-RPC methods on this server.
_xmlrpc in ./xmlrpc.inc
Performs one or more XML-RPC requests.

File

./xmlrpc.inc, line 179
Drupal XML-RPC library.

Code

function xmlrpc_message_parse($xmlrpc_message) {
  $xmlrpc_message->_parser = xml_parser_create();

  // Set XML parser to take the case of tags into account.
  xml_parser_set_option($xmlrpc_message->_parser, XML_OPTION_CASE_FOLDING, FALSE);

  // Set XML parser callback functions.
  xml_set_element_handler($xmlrpc_message->_parser, 'xmlrpc_message_tag_open', 'xmlrpc_message_tag_close');
  xml_set_character_data_handler($xmlrpc_message->_parser, 'xmlrpc_message_cdata');
  xmlrpc_message_set($xmlrpc_message);
  if (!xml_parse($xmlrpc_message->_parser, $xmlrpc_message->message)) {
    return FALSE;
  }
  xml_parser_free($xmlrpc_message->_parser);

  // Grab the error messages, if any.
  $xmlrpc_message = xmlrpc_message_get();
  if (!isset($xmlrpc_message->messagetype)) {
    return FALSE;
  }
  elseif ($xmlrpc_message->messagetype == 'fault') {
    $xmlrpc_message->fault_code = $xmlrpc_message->params[0]['faultCode'];
    $xmlrpc_message->fault_string = $xmlrpc_message->params[0]['faultString'];
  }
  return TRUE;
}