From 86f68d31d32c1796ee1699421a6c06df824253cc Mon Sep 17 00:00:00 2001 From: awjrichards Date: Sun, 11 May 2014 14:24:31 +0200 Subject: [PATCH] Make HTTPS port configurable Introduces wgHttpsPort configuration variable and makes use of it when appropriate in wfExpandUrl() Bug: 65184 Change-Id: I325ee0ff7be16de2a964fb7d8654b88cbd5fe239 --- includes/DefaultSettings.php | 8 ++++++++ includes/GlobalFunctions.php | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 5d35c4237a..d18253b657 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -7076,6 +7076,14 @@ $wgCompiledFiles = array(); */ $wgPagePropsHaveSortkey = true; +/** + * Port where you have HTTPS running + * Supports HTTPS on non-standard ports + * @see bug 65184 + * @since 1.24 + */ +$wgHttpsPort = 443; + /** * For really cool vim folding this needs to be at the end: * vim: foldmarker=@{,@} foldmethod=marker diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index d94d2f13f5..bd010437a6 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -497,7 +497,8 @@ function wfAppendQuery( $url, $query ) { * no valid URL can be constructed */ function wfExpandUrl( $url, $defaultProto = PROTO_CURRENT ) { - global $wgServer, $wgCanonicalServer, $wgInternalServer, $wgRequest; + global $wgServer, $wgCanonicalServer, $wgInternalServer, $wgRequest, + $wgHttpsPort; if ( $defaultProto === PROTO_CANONICAL ) { $serverUrl = $wgCanonicalServer; } elseif ( $defaultProto === PROTO_INTERNAL && $wgInternalServer !== false ) { @@ -536,6 +537,13 @@ function wfExpandUrl( $url, $defaultProto = PROTO_CURRENT ) { } $bits = wfParseUrl( $url ); + + // ensure proper port for HTTPS arrives in URL + // https://bugzilla.wikimedia.org/show_bug.cgi?id=65184 + if ( $defaultProto === PROTO_HTTPS && $wgHttpsPort != 443 ) { + $bits['port'] = $wgHttpsPort; + } + if ( $bits && isset( $bits['path'] ) ) { $bits['path'] = wfRemoveDotSegments( $bits['path'] ); return wfAssembleUrl( $bits ); -- 2.20.1