X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/dc1231b7312fbdca99e9e887cc2bb35a28f85cdc..refs/tags/wordpress-4.4:/wp-includes/class-IXR.php?ds=sidebyside diff --git a/wp-includes/class-IXR.php b/wp-includes/class-IXR.php index ec3f70ca..cbb65e59 100644 --- a/wp-includes/class-IXR.php +++ b/wp-includes/class-IXR.php @@ -201,6 +201,7 @@ class IXR_Message var $_value; var $_currentTag; var $_currentTagContents; + var $_valueHasType = false; // The XML parser var $_parser; @@ -268,7 +269,19 @@ class IXR_Message 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) { @@ -312,6 +325,8 @@ class IXR_Message $this->_arraystructstypes[] = 'struct'; $this->_arraystructs[] = array(); break; + case 'value': + $this->_valueHasType = false; } } @@ -343,8 +358,8 @@ class IXR_Message 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; @@ -375,6 +390,8 @@ class IXR_Message } if ($valueFlag) { + $this->_valueHasType = true; + if (count($this->_arraystructs) > 0) { // Add value to struct or array if ($this->_arraystructstypes[count($this->_arraystructstypes)-1] == 'struct') { @@ -540,7 +557,6 @@ EOD; $xml = ''."\n".$xml; $length = strlen($xml); header('Connection: close'); - header('Content-Length: '.$length); if ($charset) header('Content-Type: text/xml; charset='.$charset); else