From 3b35a3d2eceac76a41fde4f219546024962df3c2 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Fri, 19 Aug 2011 08:56:39 +0000 Subject: [PATCH] Followup r94754: move protocol expansion from getIRCLine() to inside getInternalUrl(); these internal URLs should always be fully qualified. Effectively this means that if $wgServer is protocol-relative and $wgInternalServer either isn't set or is also protocol relative (but it really shouldn't be the latter!), we'll add http:// to URLs used for Squid purging and in IRC lines. If people want those to be https:// instead, they can set $wgInternalServer accordingly. We should really, really break the connection between internal URLs used for Squid purges and URLs used for IRC, and use the latter in e-mails as well. This was briefly discussed in the CR comments on r44412 and I'll be working on that today. --- includes/RecentChange.php | 4 +--- includes/Title.php | 6 +++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/includes/RecentChange.php b/includes/RecentChange.php index a3deb91a10..b01368c7c2 100644 --- a/includes/RecentChange.php +++ b/includes/RecentChange.php @@ -707,9 +707,7 @@ class RecentChange { // XXX: *HACK^2* the preg_replace() undoes much of what getInternalURL() does, but we // XXX: need to call it so that URL paths on the Wikimedia secure server can be fixed // XXX: by a custom GetInternalURL hook --vyznev 2008-12-10 - // XXX: Also, getInternalUrl() may return a protocol-relative URL. - // XXX: In that case, expand it to an HTTP URL, even if this is an HTTPS request --catrope 2011-08-17 - $url = preg_replace( '/title=[^&]*&/', '', wfExpandUrl( $titleObj->getInternalURL( $url ), PROTO_HTTP ) ); + $url = preg_replace( '/title=[^&]*&/', '', $titleObj->getInternalURL( $url ) ); } if( isset( $this->mExtra['oldSize'] ) && isset( $this->mExtra['newSize'] ) ) { diff --git a/includes/Title.php b/includes/Title.php index 29f292e828..fab3b5bea9 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -992,6 +992,10 @@ class Title { * Get the URL form for an internal link. * - Used in various Squid-related code, in case we have a different * internal hostname for the server from the exposed one. + * + * This uses $wgInternalServer to qualify the path, or $wgServer + * if $wgInternalServer is not set. If the server variable used is + * protocol-relative, the URL will be expanded to http:// * * @param $query String an optional query string * @param $variant String language variant of url (for sr, zh..) @@ -1000,7 +1004,7 @@ class Title { public function getInternalURL( $query = '', $variant = false ) { global $wgInternalServer, $wgServer; $server = $wgInternalServer !== false ? $wgInternalServer : $wgServer; - $url = $server . $this->getLocalURL( $query, $variant ); + $url = wfExpandUrl( $server . $this->getLocalURL( $query, $variant ), PROTO_HTTP ); wfRunHooks( 'GetInternalURL', array( &$this, &$url, $query ) ); return $url; } -- 2.20.1