r99595 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99594‎ | r99595 | r99596 >
Date:23:26, 11 October 2011
Author:catrope
Status:ok
Tags:
Comment:
Contest: Various fixes for escaping, whitespace and typos
Modified paths:
  • /trunk/extensions/Contest/includes/ContestComment.php (modified) (history)
  • /trunk/extensions/Contest/includes/ContestContestant.php (modified) (history)
  • /trunk/extensions/Contest/includes/ContestUtils.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialContestSignup.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialContestant.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialEditContest.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialMyContests.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Contest/specials/SpecialMyContests.php
@@ -194,7 +194,7 @@
195195 case Contest::STATUS_FINISHED:
196196 $this->showWarning( 'contest-submission-finished' );
197197 $out->addHTML( '<br /><br /><br /><br />' );
198 - $out->returnToMain();
 198+ $out->returnToMain();
199199 break;
200200 }
201201 }
@@ -209,7 +209,7 @@
210210 */
211211 protected function handleEnabledPage( Contest $contest ) {
212212 // Check if the user is already a contestant in this contest.
213 - // If he is, reirect to submission page, else show signup form.
 213+ // If he is, redirect to submission page, else show signup form.
214214 $contestant = ContestContestant::s()->selectRow(
215215 null,
216216 array(
@@ -235,7 +235,7 @@
236236 * @param ContestContestant $contestant
237237 */
238238 protected function showSubmissionPage( ContestContestant $contestant ) {
239 - // TODO: redirects with fragment apparenelt don't work - need other solution here
 239+ // TODO: redirects with fragment apparently don't work - need other solution here
240240 if ( $this->getTitle()->getFragment() == 'new' ) {
241241 $this->showSuccess( 'contest-mycontests-signup-success' );
242242 }
Index: trunk/extensions/Contest/specials/SpecialContestant.php
@@ -41,7 +41,8 @@
4242 }
4343 else {
4444 if ( $this->getRequest()->wasPosted()
45 - && $this->getUser()->matchEditToken( $this->getRequest()->getVal( 'wpEditToken' ) ) ) {
 45+ && $this->getUser()->matchEditToken( $this->getRequest()->getVal( 'wpEditToken' ) ) )
 46+ {
4647 $this->handleSubmission( $contestant );
4748 }
4849
@@ -75,7 +76,7 @@
7677
7778 if ( $success ) {
7879 ContestContestant::s()->addToField( 'comments', 1 );
79 - }
 80+ }
8081 }
8182
8283 if ( $success && !is_null( $this->getRequest()->getVal( 'contestant-rating' ) ) ) {
@@ -174,7 +175,7 @@
175176 $stats['challenge'] = htmlspecialchars( $challengeTitles[$contestant->getField( 'challenge_id' )] );
176177
177178 if ( $contestant->getField( 'submission' ) === '' ) {
178 - $stats['submission'] = wfMsg( 'contest-contestant-notsubmitted' );
 179+ $stats['submission'] = htmlspecialchars( wfMsg( 'contest-contestant-notsubmitted' ) );
179180 }
180181 else {
181182 $stats['submission'] = '<b>' . Html::element(
@@ -187,17 +188,17 @@
188189 $countries = ContestContestant::getCountries();
189190 $stats['country'] = htmlspecialchars( $countries[$contestant->getField( 'country' )] );
190191
191 - $stats['wmf'] = wfMsg( 'contest-contestant-' . ( $contestant->getField( 'wmf' ) ? 'yes' : 'no' ) );
192 - $stats['volunteer'] = wfMsg( 'contest-contestant-' . ( $contestant->getField( 'volunteer' ) ? 'yes' : 'no' ) );
 192+ $stats['wmf'] = htmlspecialchars( wfMsg( 'contest-contestant-' . ( $contestant->getField( 'wmf' ) ? 'yes' : 'no' ) ) );
 193+ $stats['volunteer'] = htmlspecialchars( wfMsg( 'contest-contestant-' . ( $contestant->getField( 'volunteer' ) ? 'yes' : 'no' ) ) );
193194
194 - $stats['rating'] = wfMsgExt(
 195+ $stats['rating'] = htmlspecialchars( wfMsgExt(
195196 'contest-contestant-rating',
196197 'parsemag',
197198 $this->getLang()->formatNum( $contestant->getField( 'rating' ) ),
198199 $this->getLang()->formatNum( $contestant->getField( 'rating_count' ) )
199 - );
 200+ ) );
200201
201 - $stats['comments'] = $this->getLang()->formatNum( $contestant->getField( 'comments' ) );
 202+ $stats['comments'] = htmlspecialchars( $this->getLang()->formatNum( $contestant->getField( 'comments' ) ) );
202203
203204 return $stats;
204205 }
@@ -320,7 +321,7 @@
321322 'contest-contestant-comment-by',
322323 Linker::userLink( $comment->getField( 'user_id' ), $user->getName() ) .
323324 Linker::userToolLinks( $comment->getField( 'user_id' ), $user->getName() )
324 - ) . '&#160;&#160;&#160;' . $this->getLang()->timeanddate( $comment->getField( 'time' ), true )
 325+ ) . '&#160;&#160;&#160;' . htmlspecialchars( $this->getLang()->timeanddate( $comment->getField( 'time' ), true ) )
325326 );
326327
327328 $html .= Html::rawElement(
Index: trunk/extensions/Contest/specials/SpecialContestSignup.php
@@ -49,7 +49,7 @@
5050 * landing page.
5151 *
5252 * @return false|boolean
53 - */
 53+ */
5454 public function isListed() {
5555
5656 return false;
@@ -157,7 +157,7 @@
158158 }
159159 else {
160160 $out->redirect( SpecialPage::getTitleFor( 'MyContests', $contest->getField( 'name' ) )->getLocalURL() );
161 - }
 161+ }
162162 }
163163
164164 /**
@@ -174,7 +174,7 @@
175175 $form->setSubmitCallback( array( $this, 'handleSubmission' ) );
176176 $form->setSubmitText( wfMsg( 'contest-signup-submit' ) );
177177
178 - if( $form->show() ){
 178+ if( $form->show() ) {
179179 $this->showSucess( $contest );
180180 }
181181 else {
Index: trunk/extensions/Contest/specials/SpecialEditContest.php
@@ -138,6 +138,7 @@
139139 'cancelEdit',
140140 wfMsg( 'cancel' ),
141141 'cancelEdit',
 142+ // FIXME: don't use onclick, use jQuery
142143 array(
143144 'onclick' => 'window.location="' . SpecialPage::getTitleFor( 'Contests' )->getFullURL() . '";return false;'
144145 )
Index: trunk/extensions/Contest/includes/ContestUtils.php
@@ -55,7 +55,7 @@
5656
5757 // Looks like the LinkEnd hook can be used here instead of replaceRelativeLinks.
5858 // The hook could just turn relative urls into absolute ones in a nice way,
59 - // but would reauire setting some global such as $isContestEmailParse to true
 59+ // but would require setting some global such as $isContestEmailParse to true
6060 // before the parse call and to false afterwards, which also is not very nice.
6161
6262 global $wgParser;
Index: trunk/extensions/Contest/includes/ContestComment.php
@@ -113,7 +113,7 @@
114114
115115 if ( $success ) {
116116 $contestant = new ContestContestant( array( 'id' => $this->getField( 'contestant_id' ) ) );
117 - $contestant->addToField( 'comments', 1 );
 117+ $contestant->addToField( 'comments', 1 );
118118 }
119119
120120 return $success;
Index: trunk/extensions/Contest/includes/ContestContestant.php
@@ -499,13 +499,13 @@
500500 wfRunHooks( 'ContestBeforeSignupEmail', array( &$this, &$title, &$emailText, &$user, &$sender, &$senderName ) );
501501
502502 return UserMailer::send(
503 - new MailAddress( $user ),
504 - new MailAddress( $sender, $senderName ),
505 - $title,
506 - $emailText,
507 - null,
508 - 'text/html; charset=ISO-8859-1'
509 - );
 503+ new MailAddress( $user ),
 504+ new MailAddress( $sender, $senderName ),
 505+ $title,
 506+ $emailText,
 507+ null,
 508+ 'text/html; charset=ISO-8859-1'
 509+ );
510510 }
511511
512512 /**
@@ -527,13 +527,13 @@
528528 wfRunHooks( 'ContestBeforeReminderEmail', array( &$this, &$title, &$emailText, &$user, &$sender, &$senderName ) );
529529
530530 return UserMailer::send(
531 - new MailAddress( $user ),
532 - new MailAddress( $sender, $senderName ),
533 - $title,
534 - $emailText,
535 - null,
536 - 'text/html; charset=ISO-8859-1'
537 - );
 531+ new MailAddress( $user ),
 532+ new MailAddress( $sender, $senderName ),
 533+ $title,
 534+ $emailText,
 535+ null,
 536+ 'text/html; charset=ISO-8859-1'
 537+ );
538538 }
539539
540540 /**

Status & tagging log