Make WordPress Core

Changeset 45971 for trunk


Ignore:
Timestamp:
09/04/2019 04:56:33 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Improve URL validation in wp_validate_redirect().

Props vortfu, whyisjake, peterwilsoncc.

File:
1 edited

Legend:

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

    r45932 r45971  
    14061406        if ( isset( $lp['scheme'] ) && ! ( 'http' == $lp['scheme'] || 'https' == $lp['scheme'] ) ) {
    14071407            return $default;
     1408        }
     1409
     1410        if ( ! isset( $lp['host'] ) && ! empty( $lp['path'] ) && '/' !== $lp['path'][0] ) {
     1411            $path = '';
     1412            if ( ! empty( $_SERVER['REQUEST_URI'] ) ) {
     1413                $path = dirname( parse_url( 'http://placeholder' . $_SERVER['REQUEST_URI'], PHP_URL_PATH ) . '?' );
     1414            }
     1415            $location = '/' . ltrim( $path . '/', '/' ) . $location;
    14081416        }
    14091417
Note: See TracChangeset for help on using the changeset viewer.