From f7fd9adee14fc09a07f6d25310ac260293839cf1 Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Fri, 19 Feb 2021 21:13:08 +0000 Subject: [PATCH] Security: Fix bug in `wp_is_local_html_output()`. Prior to this changeset, the check for the correct RSD link output was relying on a specific protocol, although it needs to accept both the HTTP and HTTPS version of the URL. Props TimothyBlynJacobs. Fixes #52542. See #47577. Built from https://develop.svn.wordpress.org/trunk@50391 git-svn-id: http://core.svn.wordpress.org/trunk@50002 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/https-detection.php | 4 ++-- wp-includes/version.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wp-includes/https-detection.php b/wp-includes/https-detection.php index 2ced175047..7642fda3da 100644 --- a/wp-includes/https-detection.php +++ b/wp-includes/https-detection.php @@ -204,7 +204,7 @@ function wp_cron_conditionally_prevent_sslverify( $request ) { function wp_is_local_html_output( $html ) { // 1. Check if HTML includes the site's Really Simple Discovery link. if ( has_action( 'wp_head', 'rsd_link' ) ) { - $pattern = esc_url( site_url( 'xmlrpc.php?rsd', 'rpc' ) ); // See rsd_link(). + $pattern = preg_replace( '#^https?:(?=//)#', '', esc_url( site_url( 'xmlrpc.php?rsd', 'rpc' ) ) ); // See rsd_link(). return false !== strpos( $html, $pattern ); } @@ -218,7 +218,7 @@ function wp_is_local_html_output( $html ) { // 3. Check if HTML includes the site's REST API link. if ( has_action( 'wp_head', 'rest_output_link_wp_head' ) ) { // Try both HTTPS and HTTP since the URL depends on context. - $pattern = esc_url( preg_replace( '#^https?:(?=//)#', '', get_rest_url() ) ); // See rest_output_link_wp_head(). + $pattern = preg_replace( '#^https?:(?=//)#', '', esc_url( get_rest_url() ) ); // See rest_output_link_wp_head(). return false !== strpos( $html, $pattern ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 5ec3d254cc..4a02ae5c39 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.7-beta3-50390'; +$wp_version = '5.7-beta3-50391'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.