Page MenuHomePhabricator

mediawiki-1.20.3-https-detection-fix.patch

Authored By
bzimport
Nov 22 2014, 1:15 AM
Size
1 KB
Referenced Files
None
Subscribers
None

mediawiki-1.20.3-https-detection-fix.patch

diff --git a/php/includes/IP.php b/php/includes/IP.php
index 10c707e..f99e105 100644
--- a/php/includes/IP.php
+++ b/php/includes/IP.php
@@ -292,11 +292,11 @@ class IP {
* @param $defaultPort bool|int
* @return string
*/
- public static function combineHostAndPort( $host, $port, $defaultPort = false ) {
+ public static function combineHostAndPort( $host, $port, $defaultPorts = array() ) {
if ( strpos( $host, ':' ) !== false ) {
$host = "[$host]";
}
- if ( $defaultPort !== false && $port == $defaultPort ) {
+ if ( in_array( $port, $defaultPorts )) {
return $host;
} else {
return "$host:$port";
diff --git a/php/includes/WebRequest.php b/php/includes/WebRequest.php
index 96279fb..c325931 100644
--- a/php/includes/WebRequest.php
+++ b/php/includes/WebRequest.php
@@ -160,11 +160,11 @@ class WebRequest {
* @return string
*/
public static function detectServer() {
- list( $proto, $stdPort ) = self::detectProtocolAndStdPort();
+ list( $proto, $stdPorts ) = self::detectProtocolAndStdPort();
$varNames = array( 'HTTP_HOST', 'SERVER_NAME', 'HOSTNAME', 'SERVER_ADDR' );
$host = 'localhost';
- $port = $stdPort;
+ $port = $stdPorts[0];
foreach ( $varNames as $varName ) {
if ( !isset( $_SERVER[$varName] ) ) {
continue;
@@ -185,14 +185,14 @@ class WebRequest {
break;
}
- return $proto . '://' . IP::combineHostAndPort( $host, $port, $stdPort );
+ return $proto . '://' . IP::combineHostAndPort( $host, $port, $stdPorts );
}
/**
* @return array
*/
public static function detectProtocolAndStdPort() {
- return ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' ) ? array( 'https', 443 ) : array( 'http', 80 );
+ return ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] != '' && $_SERVER['HTTPS'] != 'off' ) ? array( 'https', array(80, 443) ) : array( 'http', array(80) );
}
/**

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
9792
Default Alt Text
mediawiki-1.20.3-https-detection-fix.patch (1 KB)

Event Timeline