Make WordPress Core

Ticket #63316: 63316.2.diff

File 63316.2.diff, 1.0 KB (added by johnjamesjacoby, 14 months ago)

Make sure both $original & $redirect have the expected array keys set, even if empty

  • src/wp-includes/canonical.php

     
    7777                return;
    7878        }
    7979
    80         $redirect     = $original;
    81         $redirect_url = false;
    82         $redirect_obj = false;
    83 
    8480        // Notice fixing.
    85         if ( ! isset( $redirect['path'] ) ) {
    86                 $redirect['path'] = '';
     81        if ( ! isset( $original['host'] ) ) {
     82                $original['host'] = '';
    8783        }
    88         if ( ! isset( $redirect['query'] ) ) {
    89                 $redirect['query'] = '';
     84        if ( ! isset( $original['path'] ) ) {
     85                $original['path'] = '';
    9086        }
     87        if ( ! isset( $original['query'] ) ) {
     88                $original['query'] = '';
     89        }
    9190
     91        $redirect     = $original;
     92        $redirect_url = false;
     93        $redirect_obj = false;
     94
    9295        /*
    9396         * If the original URL ended with non-breaking spaces, they were almost
    9497         * certainly inserted by accident. Let's remove them, so the reader doesn't
     
    616619        }
    617620
    618621        // Notice prevention after new parse_url( $redirect_url ) calls
     622        if ( ! isset( $redirect['host'] ) ) {
     623                $redirect['host'] = '';
     624        }
    619625        if ( ! isset( $redirect['path'] ) ) {
    620626                $redirect['path'] = '';
    621627        }