WordPress.org

Make WordPress Core

Ticket #21077: ms-settings_201308012128.php

File ms-settings_201308012128.php, 1.4 KB (added by F J Kaiser, 2 years ago)
Line 
1Index: wp-includes/ms-settings.php
2===================================================================
3--- wp-includes/ms-settings.php (revision 23294)
4+++ wp-includes/ms-settings.php (working copy)
5@@ -22,21 +22,23 @@
6 
7 if ( !isset( $current_site ) || !isset( $current_blog ) ) {
8 
9-       $domain = addslashes( $_SERVER['HTTP_HOST'] );
10+       // We don't know if $_SERVER['HTTP_HOST'] or $_SERVER['SERVER_NAME'] is set
11+       $domain = $_SERVER['HTTP_HOST'];
12+       if ( ! isset( $domain ) && ! empty( $_SERVER['SERVER_NAME'] ) ) {
13+               $domain = $_SERVER['SERVER_NAME'];
14+       }
15+       $domain = addslashes( $domain );
16+       // Handle cases with ":PORT_NR" as suffix
17        if ( false !== strpos( $domain, ':' ) ) {
18-               if ( substr( $domain, -3 ) == ':80' ) {
19-                       $domain = substr( $domain, 0, -3 );
20-                       $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 );
21-               } elseif ( substr( $domain, -4 ) == ':443' ) {
22-                       $domain = substr( $domain, 0, -4 );
23-                       $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 );
24-               } else {
25+               $domain = parse_url( $domain, PHP_URL_PATH );
26+               if ( strstr( $domain, ':' ) ) {
27                        wp_load_translations_early();
28                        wp_die( __( 'Multisite only works without the port number in the URL.' ) );
29                }
30+               $_SERVER['HTTP_HOST'] = $_SERVER['SERVER_NAME'] = $domain;
31        }
32+       $domain = rtrim( $domain, '.' );
33 
34-       $domain = rtrim( $domain, '.' );
35        $cookie_domain = $domain;
36        if ( substr( $cookie_domain, 0, 4 ) == 'www.' )
37                $cookie_domain = substr( $cookie_domain, 4 );