Make WordPress Core

Changeset 36661


Ignore:
Timestamp:
02/24/2016 12:55:01 AM (9 years ago)
Author:
SergeyBiryukov
Message:

Comments: In wp_xmlrpc_server::pingback_ping():

  • Rename $linea to $remote_source for clarity.
  • Add remote_source to comment data, so it's available to preprocess_comment and comment_post filters.
  • Pass the original (unfiltered) response source to the filters too (as remote_source_original in comment data).

Props dshanske for the original patch.
Fixes #34141.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-xmlrpc-server.php

    r36163 r36661  
    62786278            ),
    62796279        );
     6280
    62806281        $request = wp_safe_remote_get( $pagelinkedfrom, $http_api_args );
    6281         $linea = wp_remote_retrieve_body( $request );
    6282 
    6283         if ( !$linea )
     6282        $remote_source = $remote_source_original = wp_remote_retrieve_body( $request );
     6283
     6284        if ( ! $remote_source ) {
    62846285            return $this->pingback_error( 16, __( 'The source URL does not exist.' ) );
     6286        }
    62856287
    62866288        /**
     
    62896291         * @since 2.5.0
    62906292         *
    6291          * @param string $linea        Response object for the page linked from.
    6292          * @param string $pagelinkedto URL of the page linked to.
     6293         * @param string $remote_source Response source for the page linked from.
     6294         * @param string $pagelinkedto  URL of the page linked to.
    62936295         */
    6294         $linea = apply_filters( 'pre_remote_source', $linea, $pagelinkedto );
     6296        $remote_source = apply_filters( 'pre_remote_source', $remote_source, $pagelinkedto );
    62956297
    62966298        // Work around bug in strip_tags():
    6297         $linea = str_replace('<!DOC', '<DOC', $linea);
    6298         $linea = preg_replace( '/[\r\n\t ]+/', ' ', $linea ); // normalize spaces
    6299         $linea = preg_replace( "/<\/*(h1|h2|h3|h4|h5|h6|p|th|td|li|dt|dd|pre|caption|input|textarea|button|body)[^>]*>/", "\n\n", $linea );
    6300 
    6301         preg_match('|<title>([^<]*?)</title>|is', $linea, $matchtitle);
     6299        $remote_source = str_replace( '<!DOC', '<DOC', $remote_source );
     6300        $remote_source = preg_replace( '/[\r\n\t ]+/', ' ', $remote_source ); // normalize spaces
     6301        $remote_source = preg_replace( "/<\/*(h1|h2|h3|h4|h5|h6|p|th|td|li|dt|dd|pre|caption|input|textarea|button|body)[^>]*>/", "\n\n", $remote_source );
     6302
     6303        preg_match( '|<title>([^<]*?)</title>|is', $remote_source, $matchtitle );
    63026304        $title = $matchtitle[1];
    63036305        if ( empty( $title ) )
    63046306            return $this->pingback_error( 32, __('We cannot find a title on that page.' ) );
    63056307
    6306         $linea = strip_tags( $linea, '<a>' ); // just keep the tag we need
    6307 
    6308         $p = explode( "\n\n", $linea );
     6308        $remote_source = strip_tags( $remote_source, '<a>' ); // just keep the tag we need
     6309
     6310        $p = explode( "\n\n", $remote_source );
    63096311
    63106312        $preg_target = preg_quote($pagelinkedto, '|');
     
    63546356        $comment_type = 'pingback';
    63556357
    6356         $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_content', 'comment_type');
     6358        $commentdata = compact(
     6359            'comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email',
     6360            'comment_content', 'comment_type', 'remote_source', 'remote_source_original'
     6361        );
    63576362
    63586363        $comment_ID = wp_new_comment($commentdata);
Note: See TracChangeset for help on using the changeset viewer.