WordPress.org

Make WordPress Core

Ticket #21077: ms-settings_201201082128.patch

File ms-settings_201201082128.patch, 1.4 KB (added by F J Kaiser, 5 years ago)

Ignore previous patch - added .php extension per accident

  • wp-includes/ms-settings.php

     
    2222
    2323if ( !isset( $current_site ) || !isset( $current_blog ) ) {
    2424
    25         $domain = addslashes( $_SERVER['HTTP_HOST'] );
     25        // We don't know if $_SERVER['HTTP_HOST'] or $_SERVER['SERVER_NAME'] is set
     26        $domain = $_SERVER['HTTP_HOST'];
     27        if ( ! isset( $domain ) && ! empty( $_SERVER['SERVER_NAME'] ) ) {
     28                $domain = $_SERVER['SERVER_NAME'];
     29        }
     30        $domain = addslashes( $domain );
     31        // Handle cases with ":PORT_NR" as suffix
    2632        if ( false !== strpos( $domain, ':' ) ) {
    27                 if ( substr( $domain, -3 ) == ':80' ) {
    28                         $domain = substr( $domain, 0, -3 );
    29                         $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 );
    30                 } elseif ( substr( $domain, -4 ) == ':443' ) {
    31                         $domain = substr( $domain, 0, -4 );
    32                         $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 );
    33                 } else {
     33                $domain = parse_url( $domain, PHP_URL_PATH );
     34                if ( strstr( $domain, ':' ) ) {
    3435                        wp_load_translations_early();
    3536                        wp_die( __( 'Multisite only works without the port number in the URL.' ) );
    3637                }
     38                $_SERVER['HTTP_HOST'] = $_SERVER['SERVER_NAME'] = $domain;
    3739        }
     40        $domain = rtrim( $domain, '.' );
    3841
    39         $domain = rtrim( $domain, '.' );
    4042        $cookie_domain = $domain;
    4143        if ( substr( $cookie_domain, 0, 4 ) == 'www.' )
    4244                $cookie_domain = substr( $cookie_domain, 4 );