From: Antoine Musso Date: Sun, 13 Mar 2011 18:31:00 +0000 (+0000) Subject: setting servername with an IPv6 request must ensure we have both brackets X-Git-Tag: 1.31.0-rc.0~31453 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/modifier.php?a=commitdiff_plain;h=d73b3758701661729e001801d964736d18066fd9;p=lhc%2Fweb%2Fwiklou.git setting servername with an IPv6 request must ensure we have both brackets On lighttpd 1.4.28, the SERVER_NAME CGI variable is truncated at the first colon. This makes it return an incorrect value for SERVER_NAME when the user make the request to an IPv6, it outputs something like [2001. This patch make sure we have either both opening and closing brackets or no brackets at all (hence the 'xor' boolean check). +ipv6 --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 64f770d9ae..a7abbaa7a8 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -54,7 +54,12 @@ $wgSitename = 'MediaWiki'; $wgServer = ''; /** @cond file_level_code */ -if( isset( $_SERVER['SERVER_NAME'] ) ) { +if( isset( $_SERVER['SERVER_NAME'] ) + # additionially, for requests made directly to an IPv6 address we have + # to make sure the server enclose it in either [] or nothing at all + && (strpos($_SERVER['SERVER_NAME'], '[') + xor strpos( $_SERVER['SERVER_NAME'], ']')) + ) { $serverName = $_SERVER['SERVER_NAME']; } elseif( isset( $_SERVER['HOSTNAME'] ) ) { $serverName = $_SERVER['HOSTNAME'];