mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 12:50:28 +00:00
Rewrite: In url_to_postid(), bail early if the URL does not belong to the site.
Props ivankristianto, swissspidy, jkhongusc, SergeyBiryukov. Fixes #39373. git-svn-id: https://develop.svn.wordpress.org/trunk@41786 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user