* (bug 12935, 12981) Fully-qualify archive URLs in delete, revert messages
Replaced a bunch of instances of 'if-this-is-not-fully-qualified-prepend-$wgServer' with a function, wfExpandUrl()
This commit is contained in:
parent
870e2c7e32
commit
8e476b31cc
9 changed files with 32 additions and 37 deletions
|
|
@ -387,7 +387,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
|
|||
* (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
|
||||
|
|
|
|||
|
|
@ -146,17 +146,13 @@ class ChannelFeed extends FeedItem {
|
|||
* @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";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -178,21 +178,16 @@ class FileDeleteForm {
|
|||
* @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,
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class FileRevertForm {
|
|||
* pending authentication, confirmation, etc.
|
||||
*/
|
||||
public function execute() {
|
||||
global $wgOut, $wgRequest, $wgUser, $wgLang, $wgServer;
|
||||
global $wgOut, $wgRequest, $wgUser, $wgLang;
|
||||
$this->setHeaders();
|
||||
|
||||
if( wfReadOnly() ) {
|
||||
|
|
@ -71,7 +71,7 @@ class FileRevertForm {
|
|||
$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() );
|
||||
|
|
@ -87,14 +87,15 @@ class FileRevertForm {
|
|||
* 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>';
|
||||
|
|
|
|||
|
|
@ -980,6 +980,21 @@ function wfAppendQuery( $url, $query ) {
|
|||
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
|
||||
|
|
|
|||
|
|
@ -366,9 +366,8 @@ EOT
|
|||
}
|
||||
|
||||
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() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -611,11 +611,8 @@ class OutputPage {
|
|||
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");
|
||||
|
|
|
|||
|
|
@ -155,12 +155,7 @@ abstract class File {
|
|||
* @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() {
|
||||
|
|
|
|||
|
|
@ -10,11 +10,8 @@ $fullName = "$wgSitename ({$wgLanguageNames[$wgLanguageCode]})";
|
|||
$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}' );
|
||||
|
|
|
|||
Loading…
Reference in a new issue