diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index 20303dc1e7e17..b2a3db02bce49 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -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; diff --git a/tests/phpunit/tests/comment/discoverPingbackServerUri.php b/tests/phpunit/tests/comment/discoverPingbackServerUri.php new file mode 100644 index 0000000000000..e172f18c31590 --- /dev/null +++ b/tests/phpunit/tests/comment/discoverPingbackServerUri.php @@ -0,0 +1,38 @@ + array(), + 'body' => '', + '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 ); + } +}