var $_value;
var $_currentTag;
var $_currentTagContents;
+ var $_valueHasType = false;
// The XML parser
var $_parser;
xml_set_object($this->_parser, $this);
xml_set_element_handler($this->_parser, 'tag_open', 'tag_close');
xml_set_character_data_handler($this->_parser, 'cdata');
- $chunk_size = 262144; // 256Kb, parse in chunks to avoid the RAM usage on very large messages
+
+ // 256Kb, parse in chunks to avoid the RAM usage on very large messages
+ $chunk_size = 262144;
+
+ /**
+ * Filter the chunk size that can be used to parse an XML-RPC reponse message.
+ *
+ * @since 4.4.0
+ *
+ * @param int $chunk_size Chunk size to parse in bytes.
+ */
+ $chunk_size = apply_filters( 'xmlrpc_chunk_parsing_size', $chunk_size );
+
$final = false;
do {
if (strlen($this->message) <= $chunk_size) {
$this->_arraystructstypes[] = 'struct';
$this->_arraystructs[] = array();
break;
+ case 'value':
+ $this->_valueHasType = false;
}
}
break;
case 'value':
// "If no type is indicated, the type is string."
- if (trim($this->_currentTagContents) != '') {
- $value = (string)$this->_currentTagContents;
+ if ( !$this->_valueHasType ) {
+ $value = trim( $this->_currentTagContents );
$valueFlag = true;
}
break;
}
if ($valueFlag) {
+ $this->_valueHasType = true;
+
if (count($this->_arraystructs) > 0) {
// Add value to struct or array
if ($this->_arraystructstypes[count($this->_arraystructstypes)-1] == 'struct') {
$xml = '<?xml version="1.0"?>'."\n".$xml;
$length = strlen($xml);
header('Connection: close');
- header('Content-Length: '.$length);
if ($charset)
header('Content-Type: text/xml; charset='.$charset);
else