Making WordPress.org

Changeset 10497


Ignore:
Timestamp:
12/08/2020 12:22:26 AM (3 years ago)
Author:
dd32
Message:

Redirects: Trim off the sub directory path prefix before attempting to handle malformed urls.

See #5528, #5531.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/mu-plugins/pub/wporg-redirects.php

    r10488 r10497  
    119119    }
    120120
    121     $new_path = $path = $_SERVER['REQUEST_URI'];
     121    $path = $_SERVER['REQUEST_URI'] ?? '/';
     122    // Remove the site prefix.
     123    $path = preg_replace( '!^' . preg_quote( wp_parse_url( home_url( '/' ), PHP_URL_PATH ), '!' ) . '!', '/', $path );
     124
     125    $new_path = $path;
    122126
    123127    // Remove any common URL paths.
     
    128132
    129133    // Remove any trailing punctuation.
    130     $new_path = preg_replace( '!([ +\'"\W]|(?:%20))+$!', '', $new_path );
     134    $new_path = preg_replace( '!([ +\'"]|(?:%20))+$!', '', $new_path );
    131135
    132136    if ( $path === $new_path ) {
Note: See TracChangeset for help on using the changeset viewer.