r83847 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83846‎ | r83847 | r83848 >
Date:18:31, 13 March 2011
Author:hashar
Status:resolved (Comments)
Tags:
Comment:
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
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/DefaultSettings.php
@@ -54,7 +54,12 @@
5555 $wgServer = '';
5656
5757 /** @cond file_level_code */
58 -if( isset( $_SERVER['SERVER_NAME'] ) ) {
 58+if( isset( $_SERVER['SERVER_NAME'] )
 59+ # additionially, for requests made directly to an IPv6 address we have
 60+ # to make sure the server enclose it in either [] or nothing at all
 61+ && (strpos($_SERVER['SERVER_NAME'], '[')
 62+ xor strpos( $_SERVER['SERVER_NAME'], ']'))
 63+ ) {
5964 $serverName = $_SERVER['SERVER_NAME'];
6065 } elseif( isset( $_SERVER['HOSTNAME'] ) ) {
6166 $serverName = $_SERVER['HOSTNAME'];

Follow-up revisions

RevisionCommit summaryAuthorDate
r88973fix broken condition in r83847 (tested)vyznev16:14, 27 May 2011

Comments

#Comment by Ilmari Karonen (talk | contribs)   15:50, 27 May 2011

Actually, you have it backwards: the condition you added is only satisfied if SERVER_NAME contains "[" or "]", but not both.

Status & tagging log