Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/wp-includes/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -2931,7 +2931,7 @@ function discover_pingback_server_uri( $url, $deprecated = '' ) {
$pingback_str_squote = 'rel=\'pingback\'';

/** @todo Should use Filter Extension or custom preg_match instead. */
$parsed_url = parse_url( $url );
$parsed_url = wp_parse_url( $url );

if ( ! isset( $parsed_url['host'] ) ) { // Not a URL. This should never happen.
return false;
Expand Down
38 changes: 38 additions & 0 deletions tests/phpunit/tests/comment/discoverPingbackServerUri.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

/**
* @group comment
* @covers ::discover_pingback_server_uri
*
* @ticket 31384
*/
class Tests_Comment_DiscoverPingbackServerUri extends WP_UnitTestCase {

public function set_up() {
parent::set_up();
add_filter( 'pre_http_request', array( $this, 'mock_http_request' ) );
}

public function tear_down() {
remove_filter( 'pre_http_request', array( $this, 'mock_http_request' ) );
parent::tear_down();
}

public function mock_http_request() {
return array(
'headers' => array(),
'body' => '<link rel="pingback" href="https://example.com/pingback" />',
'response' => array( 'code' => 200 ),
'cookies' => array(),
);
}

/**
* @ticket 31384
*/
public function test_discovers_pingback_uri_for_schemeless_url() {
$result = discover_pingback_server_uri( '//example.com/post' );

$this->assertSame( 'https://example.com/pingback', $result );
}
}
Loading