]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/class-IXR.php
WordPress 4.4
[autoinstalls/wordpress.git] / wp-includes / class-IXR.php
index ec3f70ca71f71703dcf96c7ffb715fe02b177f86..cbb65e599aefb3fcb44c60fd051e30a47349c040 100644 (file)
@@ -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 = '<?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