Replaced a bunch of instances of 'if-this-is-not-fully-qualified-prepend-$wgServer' with a function, wfExpandUrl()
* (bug 7681, 11559) Cookie values no longer override GET and POST variables.
* (bug 5262) Fully-qualified $wgStylePath no longer corrupted on XML feeds
* (bug 3269) Inaccessible titles ending in '/.' or '/..' now forbidden.
-* (bug 12935) Fully-qualify archive URLs correctly in deletion message
+* (bug 12935, 12981) Fully-qualify archive URLs in delete, revert messages
* (bug 12938) Fix template expansion and 404 returns for action=raw with section
* (bug 11567) Fix error checking for PEAR::Mail. UserMailer::send() now returns
true-or-WikiError, which seems to be the calling convention expected by half
* @private
*/
function outXmlHeader() {
- global $wgServer, $wgStylePath, $wgStyleVersion;
- if( substr( $wgStylePath, 0, 1 ) == '/' ) {
- $stylePath = $wgServer . $wgStylePath;
- } else {
- $stylePath = $wgStylePath;
- }
+ global $wgStylePath, $wgStyleVersion;
$this->httpHeaders();
echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
echo '<?xml-stylesheet type="text/css" href="' .
- htmlspecialchars( "$stylePath/common/feed.css?$wgStyleVersion" ) . '"?' . ">\n";
+ htmlspecialchars( wfExpandUrl( "$wgStylePath/common/feed.css?$wgStyleVersion" ) ) .
+ '"?' . ">\n";
}
}
* @return string
*/
private function prepareMessage( $message ) {
- global $wgLang, $wgServer;
+ global $wgLang;
if( $this->oldimage ) {
$url = $this->file->getArchiveUrl( $this->oldimage );
- if( substr( $url, 0, 1 ) == '/' ) {
- // Fully-qualify the URL if necessary
- $url = $wgServer . $url;
- }
return wfMsgExt(
"{$message}-old", # To ensure grep will find them: 'filedelete-intro-old', 'filedelete-nofile-old', 'filedelete-success-old'
'parse',
$this->title->getText(),
$wgLang->date( $this->getTimestamp(), true ),
$wgLang->time( $this->getTimestamp(), true ),
- $url
- );
+ wfExpandUrl( $this->file->getArchiveUrl( $this->oldimage ) ) );
} else {
return wfMsgExt(
$message,
* pending authentication, confirmation, etc.
*/
public function execute() {
- global $wgOut, $wgRequest, $wgUser, $wgLang, $wgServer;
+ global $wgOut, $wgRequest, $wgUser, $wgLang;
$this->setHeaders();
if( wfReadOnly() ) {
$wgOut->addHtml( wfMsgExt( 'filerevert-success', 'parse', $this->title->getText(),
$wgLang->date( $this->getTimestamp(), true ),
$wgLang->time( $this->getTimestamp(), true ),
- $wgServer . $this->file->getArchiveUrl( $this->oldimage ) ) );
+ wfExpandUrl( $this->file->getArchiveUrl( $this->oldimage ) ) ) );
$wgOut->returnToMain( false, $this->title );
} else {
$wgOut->addWikiText( $status->getWikiText() );
* Show the confirmation form
*/
private function showForm() {
- global $wgOut, $wgUser, $wgRequest, $wgLang, $wgContLang, $wgServer;
+ global $wgOut, $wgUser, $wgRequest, $wgLang, $wgContLang;
$timestamp = $this->getTimestamp();
$form = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getAction() ) );
$form .= Xml::hidden( 'wpEditToken', $wgUser->editToken( $this->oldimage ) );
$form .= '<fieldset><legend>' . wfMsgHtml( 'filerevert-legend' ) . '</legend>';
$form .= wfMsgExt( 'filerevert-intro', 'parse', $this->title->getText(),
- $wgLang->date( $timestamp, true ), $wgLang->time( $timestamp, true ), $wgServer . $this->file->getArchiveUrl( $this->oldimage ) );
+ $wgLang->date( $timestamp, true ), $wgLang->time( $timestamp, true ),
+ wfExpandUrl( $this->file->getArchiveUrl( $this->oldimage ) ) );
$form .= '<p>' . Xml::inputLabel( wfMsg( 'filerevert-comment' ), 'wpComment', 'wpComment',
60, wfMsgForContent( 'filerevert-defaultcomment',
$wgContLang->date( $timestamp, false, false ), $wgContLang->time( $timestamp, false, false ) ) ) . '</p>';
return $url;
}
+/**
+ * Expand a potentially local URL to a fully-qualified URL.
+ * Assumes $wgServer is correct. :)
+ * @param string $url, either fully-qualified or a local path + query
+ * @return string Fully-qualified URL
+ */
+function wfExpandUrl( $url ) {
+ if( substr( $url, 0, 1 ) == '/' ) {
+ global $wgServer;
+ return $wgServer . $url;
+ } else {
+ return $url;
+ }
+}
+
/**
* This is obsolete, use SquidUpdate::purge()
* @deprecated
}
function getUploadUrl() {
- global $wgServer;
$uploadTitle = SpecialPage::getTitleFor( 'Upload' );
- return $wgServer . $uploadTitle->getLocalUrl( 'wpDestFile=' . urlencode( $this->img->getName() ) );
+ return $uploadTitle->getFullUrl( 'wpDestFile=' . urlencode( $this->img->getName() ) );
}
/**
wfProfileIn( $fname );
if ( '' != $this->mRedirect ) {
- if( substr( $this->mRedirect, 0, 4 ) != 'http' ) {
- # Standards require redirect URLs to be absolute
- global $wgServer;
- $this->mRedirect = $wgServer . $this->mRedirect;
- }
+ # Standards require redirect URLs to be absolute
+ $this->mRedirect = wfExpandUrl( $this->mRedirect );
if( $this->mRedirectCode == '301') {
if( !$wgDebugRedirects ) {
$wgRequest->response()->header("HTTP/1.1 {$this->mRedirectCode} Moved Permanently");
* @return string
*/
public function getFullUrl() {
- $url = $this->getUrl();
- if( substr( $url, 0, 1 ) == '/' ) {
- global $wgServer;
- return $wgServer . $url;
- }
- return $url;
+ return wfExpandUrl( $this->getUrl() );
}
function getViewURL() {
$shortName = htmlspecialchars( mb_substr( $fullName, 0, 24 ) );
$siteName = htmlspecialchars( $fullName );
-if ( !preg_match( '/^https?:/', $wgFavicon ) ) {
- $favicon = htmlspecialchars( $wgServer . $wgFavicon );
-} else {
- $favicon = htmlspecialchars( $wgFavicon );
-}
+
+$favicon = htmlspecialchars( wfExpandUrl( $wgFavicon ) );
$title = SpecialPage::getTitleFor( 'Search' );
$template = $title->escapeFullURL( 'search={searchTerms}' );