r50511 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50510‎ | r50511 | r50512 >
Date:09:43, 12 May 2009
Author:jojo
Status:resolved (Comments)
Tags:
Comment:
removed double escaping, and thus the need to unescape URL params
Modified paths:
  • /trunk/extensions/Collection/Collection.body.php (modified) (history)
  • /trunk/extensions/Collection/Collection.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Collection/Collection.hooks.php
@@ -194,13 +194,13 @@
195195 array( 'onclick' => "collectionCall('AddCategory', ['addcategory', wgTitle]); return false;",
196196 'rel' => 'nofollow',
197197 'title' => wfMsg( "coll-add_category_tooltip" ), ),
198 - array( 'cattitle' => $wgTitle->getPartialURL() ),
199 - array( 'known', 'noclasses', 'noescape' )
 198+ array( 'cattitle' => urldecode( $wgTitle->getPartialURL() ) ),
 199+ array( 'known', 'noclasses' )
200200 )
201201 );
202202
203203 } else if( $ajaxHint || in_array( $namespace, $wgCollectionArticleNamespaces ) ) {
204 - $params = array( 'arttitle' => $wgTitle->getPrefixedUrl() );
 204+ $params = array( 'arttitle' => urldecode( $wgTitle->getPrefixedUrl() ) );
205205 if ( !is_null( $wgArticle ) ) {
206206 $oldid = $wgArticle->getOldID();
207207 $params['oldid'] = $oldid;
Index: trunk/extensions/Collection/Collection.body.php
@@ -55,7 +55,7 @@
5656 self::limitExceeded();
5757 return;
5858 }
59 - $title_url = urldecode( $wgRequest->getVal( 'arttitle', '' ) );
 59+ $title_url = $wgRequest->getVal( 'arttitle', '' );
6060 $oldid = $wgRequest->getInt( 'oldid', 0 );
6161 $title = Title::newFromURL( $title_url );
6262 $this->addArticle( $title, $oldid );
@@ -68,7 +68,7 @@
6969 $wgOut->redirect( $redirectURL );
7070 return;
7171 case 'remove_article/':
72 - $title_url = urldecode( $wgRequest->getVal( 'arttitle', '' ) );
 72+ $title_url = $wgRequest->getVal( 'arttitle', '' );
7373 $oldid = $wgRequest->getInt( 'oldid', 0 );
7474 $title = Title::newFromURL( $title_url );
7575 self::removeArticle( $title, $oldid );
@@ -96,7 +96,7 @@
9797 $wgOut->redirect( SkinTemplate::makeSpecialUrl( 'Book' ) );
9898 return;
9999 case 'add_category/':
100 - $title = Title::makeTitleSafe( NS_CATEGORY, urldecode( $wgRequest->getVal( 'cattitle', '' ) ) );
 100+ $title = Title::makeTitleSafe( NS_CATEGORY, $wgRequest->getVal( 'cattitle', '' ) );
101101 if ( self::addCategory( $title ) ) {
102102 self::limitExceeded();
103103 return;
@@ -116,7 +116,7 @@
117117 $wgOut->redirect( SkinTemplate::makeSpecialUrl( 'Book' ) );
118118 return;
119119 case 'load_collection/':
120 - $title = Title::newFromText( urldecode( $wgRequest->getVal( 'colltitle', '' ) ) );
 120+ $title = Title::newFromText( $wgRequest->getVal( 'colltitle', '' ) );
121121 if ( $wgRequest->getVal( 'cancel' ) ) {
122122 $wgOut->redirect( $title->getFullURL() );
123123 return;
@@ -135,12 +135,12 @@
136136 $this->renderLoadOverwritePage( $title );
137137 return;
138138 case 'order_collection/':
139 - $title = Title::newFromText( urldecode( $wgRequest->getVal( 'colltitle', '' ) ) );
 139+ $title = Title::newFromText( $wgRequest->getVal( 'colltitle', '' ) );
140140 $collection = $this->loadCollection( $title );
141141 $partner = $wgRequest->getVal( 'partner', 'pediapress' );
142142 return $this->postZIP( $collection, $partner );
143143 case 'save_collection/':
144 - $collTitle = urldecode( $wgRequest->getVal( 'colltitle' ) );
 144+ $collTitle = $wgRequest->getVal( 'colltitle' );
145145 if ( $wgRequest->getVal( 'overwrite' ) && !empty( $collTitle ) ) {;
146146 $title = Title::newFromText( $collTitle );
147147 $this->saveCollection( $title, $overwrite=true );
@@ -152,14 +152,14 @@
153153 $saveCalled = false;
154154 if ( $collType == 'personal' ) {
155155 $userPageTitle = $wgUser->getUserPage()->getPrefixedText();
156 - $name = urldecode( $wgRequest->getVal( 'pcollname', '' ) );
 156+ $name = $wgRequest->getVal( 'pcollname', '' );
157157 if ( !empty( $name ) ) {
158158 $title = Title::newFromText( $userPageTitle . '/' . wfMsgForContent( 'coll-collections' ) . '/' . $name );
159159 $saveCalled = true;
160160 $saved = $this->saveCollection( $title, $overwrite );
161161 }
162162 } else if ( $collType == 'community' ) {
163 - $name = urldecode( $wgRequest->getVal( 'ccollname', '' ) );
 163+ $name = $wgRequest->getVal( 'ccollname', '' );
164164 if ( !empty( $name ) ) {
165165 $title = Title::makeTitle( $wgCommunityCollectionNamespace, wfMsgForContent( 'coll-collections' ) . '/' . $name );
166166 $saveCalled = true;
@@ -188,11 +188,11 @@
189189 case 'download/':
190190 return $this->download();
191191 case 'render_article/':
192 - $title = Title::newFromText( urldecode( $wgRequest->getVal( 'arttitle', '' ) ) );
 192+ $title = Title::newFromText( $wgRequest->getVal( 'arttitle', '' ) );
193193 $oldid = $wgRequest->getInt( 'oldid', 0 );
194194 return $this->renderArticle( $title, $oldid, $wgRequest->getVal( 'writer', 'rl' ) );
195195 case 'render_collection/':
196 - $title = Title::newFromText( urldecode( $wgRequest->getVal( 'colltitle', '' ) ));
 196+ $title = Title::newFromText( $wgRequest->getVal( 'colltitle', '' ));
197197 $collection = $this->loadCollection( $title );
198198 if ( $collection ) {
199199 $this->renderCollection( $collection, $title, $wgRequest->getVal( 'writer', 'rl' ) );

Comments

#Comment by Brion VIBBER (talk | contribs)   20:44, 12 May 2009
urldecode( $wgTitle->getPartialURL() ) )

I'm pretty sure you just want something like $wgTitle->getText() here?

#Comment by Jbeigel (talk | contribs)   09:10, 13 May 2009

Yes. Thanks, changed in r50542.

Status & tagging log