Skip to content
Snippets Groups Projects
Commit 204b27c8 authored by Michael Hamann's avatar Michael Hamann
Browse files

Fix getBaseURL for literal IPv6 addresses in URLs (RFC 2732) + test case

parent 1b052f5c
No related branches found
Tags develsnap_2007-06-01
No related merge requests found
......@@ -275,6 +275,31 @@ class init_getBaseURL_test extends UnitTestCase {
$this->assertEqual(getBaseURL(true),$correct_result);
}
}
/**
* Absolute URL with IPv6 domain name.
* lighttpd, fastcgi
*
* data provided by Michael Hamann <michael@content-space.de>
*/
function test12() {
global $conf;
$conf['basedir'] = '';
$conf['baseurl'] = '';
$conf['canonical'] = 0;
$_SERVER['DOCUMENT_ROOT'] = '/srv/http/';
$_SERVER['HTTP_HOST'] = '[fd00::6592:39ed:a2ed:2c78]';
$_SERVER['SCRIPT_FILENAME'] = '/srv/http/~michitux/dokuwiki/doku.php';
$_SERVER['REQUEST_URI'] = '/~michitux/dokuwiki/doku.php?do=debug';
$_SERVER['SCRIPT_NAME'] = '/~michitux/dokuwiki/doku.php';
$_SERVER['PATH_INFO'] = null;
$_SERVER['PATH_TRANSLATED'] = null;
$_SERVER['PHP_SELF'] = '/~michitux/dokuwiki/doku.php';
$_SERVER['SERVER_PORT'] = '80';
$_SERVER['SERVER_NAME'] = '[fd00';
$this->assertEqual(getBaseURL(true), 'http://[fd00::6592:39ed:a2ed:2c78]/~michitux/dokuwiki/');
}
}
//Setup VIM: ex: et ts=2 :
......@@ -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') {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment