Rewrite: In `url_to_postid()`, bail early if the URL does not belong to the site.

Props ivankristianto, swissspidy, jkhongusc, SergeyBiryukov.
Fixes #39373.
Built from https://develop.svn.wordpress.org/trunk@41786


git-svn-id: http://core.svn.wordpress.org/trunk@41620 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2017-10-06 23:29:51 +00:00
parent 6ecdbe6e0e
commit 2ae2b1269a
2 changed files with 9 additions and 1 deletions

View File

@ -471,6 +471,14 @@ function url_to_postid( $url ) {
*/
$url = apply_filters( 'url_to_postid', $url );
$url_host = str_replace( 'www.', '', parse_url( $url, PHP_URL_HOST ) );
$home_url_host = str_replace( 'www.', '', parse_url( home_url(), PHP_URL_HOST ) );
// Bail early if the URL does not belong to this site.
if ( $url_host && $url_host !== $home_url_host ) {
return 0;
}
// First, check to see if there is a 'p=N' or 'page_id=N' to match against
if ( preg_match('#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values) ) {
$id = absint($values[2]);

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-beta1-41785';
$wp_version = '4.9-beta1-41786';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.