From 7c66e0648a8e5eed5c7ed7d355d76d134de9481d Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 24 Feb 2016 00:55:26 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@36661 git-svn-id: http://core.svn.wordpress.org/trunk@36628 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-xmlrpc-server.php | 31 +++++++++++++++----------- wp-includes/version.php | 2 +- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/wp-includes/class-wp-xmlrpc-server.php b/wp-includes/class-wp-xmlrpc-server.php index 8660bfdc5a..c331591dcf 100644 --- a/wp-includes/class-wp-xmlrpc-server.php +++ b/wp-includes/class-wp-xmlrpc-server.php @@ -6277,35 +6277,37 @@ class wp_xmlrpc_server extends IXR_Server { 'X-Pingback-Forwarded-For' => $remote_ip, ), ); - $request = wp_safe_remote_get( $pagelinkedfrom, $http_api_args ); - $linea = wp_remote_retrieve_body( $request ); - if ( !$linea ) + $request = wp_safe_remote_get( $pagelinkedfrom, $http_api_args ); + $remote_source = $remote_source_original = wp_remote_retrieve_body( $request ); + + if ( ! $remote_source ) { return $this->pingback_error( 16, __( 'The source URL does not exist.' ) ); + } /** * Filter the pingback remote source. * * @since 2.5.0 * - * @param string $linea Response object for the page linked from. - * @param string $pagelinkedto URL of the page linked to. + * @param string $remote_source Response source for the page linked from. + * @param string $pagelinkedto URL of the page linked to. */ - $linea = apply_filters( 'pre_remote_source', $linea, $pagelinkedto ); + $remote_source = apply_filters( 'pre_remote_source', $remote_source, $pagelinkedto ); // Work around bug in strip_tags(): - $linea = str_replace(']*>/", "\n\n", $linea ); + $remote_source = str_replace( ']*>/", "\n\n", $remote_source ); - preg_match('|([^<]*?)|is', $linea, $matchtitle); + preg_match( '|([^<]*?)|is', $remote_source, $matchtitle ); $title = $matchtitle[1]; if ( empty( $title ) ) return $this->pingback_error( 32, __('We cannot find a title on that page.' ) ); - $linea = strip_tags( $linea, '' ); // just keep the tag we need + $remote_source = strip_tags( $remote_source, '' ); // just keep the tag we need - $p = explode( "\n\n", $linea ); + $p = explode( "\n\n", $remote_source ); $preg_target = preg_quote($pagelinkedto, '|'); @@ -6353,7 +6355,10 @@ class wp_xmlrpc_server extends IXR_Server { $this->escape($comment_content); $comment_type = 'pingback'; - $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_content', 'comment_type'); + $commentdata = compact( + 'comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', + 'comment_content', 'comment_type', 'remote_source', 'remote_source_original' + ); $comment_ID = wp_new_comment($commentdata); diff --git a/wp-includes/version.php b/wp-includes/version.php index bf8fcf1e36..6f3973dc09 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.5-alpha-36660'; +$wp_version = '4.5-alpha-36661'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.