Fix issue for PHP 5.4.8 where the host part from parse_url seems to also include the port as well.

This commit is contained in:
Gary Jones 2012-11-18 01:18:11 +00:00
parent dc7230cbb4
commit bebf65bfed
1 changed files with 10 additions and 2 deletions

View File

@ -174,8 +174,16 @@ class OAuthRequest
$parts = parse_url($this->http_url);
$scheme = (isset($parts['scheme'])) ? $parts['scheme'] : 'http';
$port = (isset($parts['port'])) ? $parts['port'] : (($scheme == 'https') ? '443' : '80');
$host = (isset($parts['host'])) ? $parts['host'] : '';
$port = (isset($parts['port'])) ? $parts['port'] : '';
if (isset($parts['host'])) {
// parse_url in PHP 5.4.8 includes the port in the host, so we need to strip it.
$host_and_maybe_port = explode(':', $parts['host']);
$host = $host_and_maybe_port[0];
} else {
$host = '';
}
// For PHP 5.4+, use:
// $host = (isset($parts['host'])) ? explode(':', $parts['host'])[0] : '';
$path = (isset($parts['path'])) ? $parts['path'] : '';
if (($scheme == 'https' && $port != '443')