From 775154ca2137e2c253deeafe9497579c56bd35f0 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Sun, 26 Jul 2009 10:34:03 +0000 Subject: [PATCH] Fix r53270: drop &returntoquery parameter if empty, and prevent Special:Userlogin from returning to itself, creating very long looplike URLs --- includes/SkinTemplate.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index c47b5c38f8..0a4fb4e675 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -164,6 +164,8 @@ class SkinTemplate extends Skin { $this->thisurl = $this->mTitle->getPrefixedURL(); $query = $wgRequest->getValues(); unset( $query['title'] ); + unset( $query['returnto'] ); + unset( $query['returntoquery'] ); $this->thisquery = wfUrlencode( wfArrayToCGI( $query ) ); $this->loggedin = $wgUser->isLoggedIn(); $this->iscontent = ( $this->mTitle->getNamespace() != NS_SPECIAL ); @@ -516,6 +518,11 @@ class SkinTemplate extends Skin { /* set up the default links for the personal toolbar */ $personal_urls = array(); + $page = $wgRequest->getVal( 'returnto', $this->thisurl ); + $query = $wgRequest->getVal( 'returntoquery', $this->thisquery ); + $returnto = "returnto=$page"; + if( $this->thisquery != '' ) + $returnto .= "&returntoquery=$query"; if( $this->loggedin ) { $personal_urls['userpage'] = array( 'text' => $this->username, @@ -568,7 +575,7 @@ class SkinTemplate extends Skin { $personal_urls['logout'] = array( 'text' => wfMsg( 'userlogout' ), 'href' => self::makeSpecialUrl( 'Userlogout', - $title->isSpecial( 'Preferences' ) ? '' : "returnto={$this->thisurl}&returntoquery={$this->thisquery}" + $title->isSpecial( 'Preferences' ) ? '' : $returnto ), 'active' => false ); @@ -595,13 +602,13 @@ class SkinTemplate extends Skin { ); $personal_urls['anonlogin'] = array( 'text' => wfMsg( $loginlink ), - 'href' => self::makeSpecialUrl( 'Userlogin', "returnto={$this->thisurl}&returntoquery={$this->thisquery}" ), + 'href' => self::makeSpecialUrl( 'Userlogin', $returnto ), 'active' => $title->isSpecial( 'Userlogin' ) ); } else { $personal_urls['login'] = array( 'text' => wfMsg( $loginlink ), - 'href' => self::makeSpecialUrl( 'Userlogin', "returnto={$this->thisurl}&returntoquery={$this->thisquery}" ), + 'href' => self::makeSpecialUrl( 'Userlogin', $returnto ), 'active' => $title->isSpecial( 'Userlogin' ) ); } -- 2.20.1