Make WordPress Core


Ignore:
Timestamp:
10/06/2017 11:28:38 PM (7 years ago)
Author:
SergeyBiryukov
Message:

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

Props ivankristianto, swissspidy, jkhongusc, SergeyBiryukov.
Fixes #39373.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rewrite.php

    r37544 r41786  
    472472    $url = apply_filters( 'url_to_postid', $url );
    473473
     474    $url_host      = str_replace( 'www.', '', parse_url( $url, PHP_URL_HOST ) );
     475    $home_url_host = str_replace( 'www.', '', parse_url( home_url(), PHP_URL_HOST ) );
     476
     477    // Bail early if the URL does not belong to this site.
     478    if ( $url_host && $url_host !== $home_url_host ) {
     479        return 0;
     480    }
     481
    474482    // First, check to see if there is a 'p=N' or 'page_id=N' to match against
    475483    if ( preg_match('#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values) )   {
Note: See TracChangeset for help on using the changeset viewer.