From 874fa5ddbf4c0001f5560316f04f11b865e1028e Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sat, 5 Nov 2005 10:53:21 +0000 Subject: [PATCH] * Fix WebRequest::getRequestURL() to strip off the host bits squid prepends Corrects self-link in Atom 1.0 feeds. --- RELEASE-NOTES | 1 + includes/WebRequest.php | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index d569a51463..8dd1d55f01 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -208,6 +208,7 @@ fully support the editing toolbar, but was found to be too confusing. * (bug 3666) Don't spew PHP warnings in prefs on unrecognized site language * (bug 2392) Fix Atom items content type, upgrade to Atom 1.0 * Allow $wgFeedCacheTimeout of 0 to disable feed caching +* Fix WebRequest::getRequestURL() to strip off the host bits squid prepends === Caveats === diff --git a/includes/WebRequest.php b/includes/WebRequest.php index 24077180a7..400392fe69 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -281,7 +281,13 @@ class WebRequest { * @return string */ function getRequestURL() { - return $_SERVER['REQUEST_URI']; + $base = $_SERVER['REQUEST_URI']; + if( $base{0} == '/' ) { + return $base; + } else { + // We may get paths with a host prepended; strip it. + return preg_replace( '!^[^:]+://[^/]+/!', '/', $base ); + } } /** -- 2.20.1