From d73b3758701661729e001801d964736d18066fd9 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 13 Mar 2011 18:31:00 +0000 Subject: [PATCH] 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 --- includes/DefaultSettings.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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']; -- 2.20.1