Make WordPress Core

Changeset 45974


Ignore:
Timestamp:
09/04/2019 05:04:15 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Improve URL validation in wp_validate_redirect().

Merges [45971] to the 5.0 branch.
Props vortfu, whyisjake, peterwilsoncc.

Location:
branches/5.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0

  • branches/5.0/src/wp-includes/pluggable.php

    r43827 r45974  
    13461346    if ( isset($lp['scheme']) && !('http' == $lp['scheme'] || 'https' == $lp['scheme']) )
    13471347        return $default;
     1348
     1349    if ( ! isset( $lp['host'] ) && ! empty( $lp['path'] ) && '/' !== $lp['path'][0] ) {
     1350        $path = '';
     1351        if ( ! empty( $_SERVER['REQUEST_URI'] ) ) {
     1352            $path = dirname( parse_url( 'http://placeholder' . $_SERVER['REQUEST_URI'], PHP_URL_PATH ) . '?' );
     1353        }
     1354        $location = '/' . ltrim( $path . '/', '/' ) . $location;
     1355    }
    13481356
    13491357    // Reject if certain components are set but host is not. This catches urls like https:host.com for which parse_url does not set the host field.
Note: See TracChangeset for help on using the changeset viewer.