~ubuntu-branches/debian/jessie/wordpress/jessie

« back to all changes in this revision

Viewing changes to wp-includes/class-IXR.php

  • Committer: Package Import Robot
  • Author(s): Craig Small
  • Date: 2014-08-07 18:26:39 UTC
  • mfrom: (1.2.37)
  • Revision ID: package-import@ubuntu.com-20140807182639-sr9h41nr2yud1de6
Tags: 3.9.2+dfsg-1
* New Upstream release
* Fixes XML Security bug Closes: #757312

Show diffs side-by-side

added added

removed removed

Lines of Context:
203
203
    {
204
204
        // first remove the XML declaration
205
205
        // merged from WP #10698 - this method avoids the RAM usage of preg_replace on very large messages
206
 
        $header = preg_replace( '/<\?xml.*?\?'.'>/', '', substr($this->message, 0, 100), 1);
207
 
        $this->message = substr_replace($this->message, $header, 0, 100);
208
 
        if (trim($this->message) == '') {
209
 
            return false;
210
 
        }
 
206
        $header = preg_replace( '/<\?xml.*?\?'.'>/s', '', substr( $this->message, 0, 100 ), 1 );
 
207
        $this->message = trim( substr_replace( $this->message, $header, 0, 100 ) );
 
208
        if ( '' == $this->message ) {
 
209
            return false;
 
210
        }
 
211
 
 
212
        // Then remove the DOCTYPE
 
213
        $header = preg_replace( '/^<!DOCTYPE[^>]*+>/i', '', substr( $this->message, 0, 200 ), 1 );
 
214
        $this->message = trim( substr_replace( $this->message, $header, 0, 200 ) );
 
215
        if ( '' == $this->message ) {
 
216
            return false;
 
217
        }
 
218
 
 
219
        // Check that the root tag is valid
 
220
        $root_tag = substr( $this->message, 0, strcspn( substr( $this->message, 0, 20 ), "> \t\r\n" ) );
 
221
        if ( '<!DOCTYPE' === strtoupper( $root_tag ) ) {
 
222
            return false;
 
223
        }
 
224
        if ( ! in_array( $root_tag, array( '<methodCall', '<methodResponse', '<fault' ) ) ) {
 
225
            return false;
 
226
        }
 
227
 
 
228
        // Bail if there are too many elements to parse
 
229
        $element_limit = 30000;
 
230
        if ( function_exists( 'apply_filters' ) ) {
 
231
            $element_limit = apply_filters( 'xmlrpc_element_limit', $element_limit );
 
232
        }
 
233
        if ( $element_limit && 2 * $element_limit < substr_count( $this->message, '<' ) ) {
 
234
            return false;
 
235
        }
 
236
 
211
237
        $this->_parser = xml_parser_create();
212
238
        // Set XML parser to take the case of tags in to account
213
239
        xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false);