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.


git-svn-id: https://develop.svn.wordpress.org/trunk@50391 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Felix Arntz
2021-02-19 21:11:02 +00:00
parent d77042872c
commit c8bbd79d2d
2 changed files with 9 additions and 2 deletions

View File

@@ -171,6 +171,7 @@ class Tests_HTTPS_Detection extends WP_UnitTestCase {
/**
* @ticket 47577
* @ticket 52542
*/
public function test_wp_is_local_html_output_via_rsd_link() {
// HTML includes RSD link.
@@ -183,6 +184,12 @@ class Tests_HTTPS_Detection extends WP_UnitTestCase {
$html = $this->get_sample_html_string( $head_tag );
$this->assertTrue( wp_is_local_html_output( $html ) );
// HTML includes RSD link with alternative URL scheme.
$head_tag = get_echo( 'rsd_link' );
$head_tag = false !== strpos( $head_tag, 'https://' ) ? str_replace( 'https://', 'http://', $head_tag ) : str_replace( 'http://', 'https://', $head_tag );
$html = $this->get_sample_html_string( $head_tag );
$this->assertTrue( wp_is_local_html_output( $html ) );
// HTML does not include RSD link.
$html = $this->get_sample_html_string();
$this->assertFalse( wp_is_local_html_output( $html ) );