diff options
author | Michael Hamann <michael@content-space.de> | 2011-01-16 22:23:54 +0100 |
---|---|---|
committer | Michael Hamann <michael@content-space.de> | 2011-01-16 22:43:34 +0100 |
commit | 204b27c8e0c1bcfa6810ee45bd12fda3f5d83960 (patch) | |
tree | b5a4587e51437888ab5b8bd1e7d04cdbee76b311 /inc/init.php | |
parent | 1b052f5cb72bee256af579602cbbed59492b2759 (diff) | |
download | rpg-204b27c8e0c1bcfa6810ee45bd12fda3f5d83960.tar.gz rpg-204b27c8e0c1bcfa6810ee45bd12fda3f5d83960.tar.bz2 |
Fix getBaseURL for literal IPv6 addresses in URLs (RFC 2732) + test case
Diffstat (limited to 'inc/init.php')
-rw-r--r-- | inc/init.php | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/inc/init.php b/inc/init.php index 3b438f15b..6f4ba1ca9 100644 --- a/inc/init.php +++ b/inc/init.php @@ -420,9 +420,13 @@ function getBaseURL($abs=null){ //split hostheader into host and port if(isset($_SERVER['HTTP_HOST'])){ - list($host,$port) = explode(':',$_SERVER['HTTP_HOST']); + $parsed_host = parse_url('http://'.$_SERVER['HTTP_HOST']); + $host = $parsed_host['host']; + $port = $parsed_host['port']; }elseif(isset($_SERVER['SERVER_NAME'])){ - list($host,$port) = explode(':',$_SERVER['SERVER_NAME']); + $parsed_host = parse_url('http://'.$_SERVER['SERVER_NAME']); + $host = $parsed_host['host']; + $port = $parsed_host['port']; }else{ $host = php_uname('n'); $port = ''; @@ -431,6 +435,11 @@ function getBaseURL($abs=null){ if(!$port && isset($_SERVER['SERVER_PORT'])) { $port = $_SERVER['SERVER_PORT']; } + + if(is_null($port)){ + $port = ''; + } + if(!is_ssl()){ $proto = 'http://'; if ($port == '80') { |