r110407 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110406‎ | r110407 | r110408 >
Date:16:54, 31 January 2012
Author:gregchiasson
Status:ok (Comments)
Tags:aft 
Comment:
AFT5 - Fix the way links to user pages or contributions (for anonymous) are built, per comments on r109833
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php
@@ -524,8 +524,6 @@
525525 }
526526
527527 private function renderBucket3( $record ) {
528 - $name = htmlspecialchars( $record[0]->user_name );
529 - $rating = htmlspecialchars( $record['rating']->aa_response_rating );
530528 $class = $record['rating']->aa_response_rating >= 3 ? 'positive' : 'negative';
531529
532530 return $this->feedbackHead( 'articlefeedbackv5-form3-header', $class, $record[0], $record['rating']->aa_response_rating )
@@ -541,7 +539,6 @@
542540 }
543541
544542 private function renderBucket5( $record ) {
545 - $name = htmlspecialchars( $record[0]->user_name );
546543 $body = '<ul>';
547544 $total = 0;
548545 $count = 0;
@@ -629,12 +626,18 @@
630627
631628 private function feedbackHead( $message, $class, $record, $extra = '' ) {
632629 $name = htmlspecialchars( $record->user_name );
633 - $link = !$record->af_user_ip ? "User:$name" : "Special:Contributions/$name";
634630 $gender = $name;
 631+ if( $record->af_user_ip ) {
 632+ // Anonymous user, go to contributions page.
 633+ $title = SpecialPage::getTitleFor( 'Contributions', $record->user_name );
 634+ } else {
 635+ // Registered user, go to user page.
 636+ $title = Title::makeTitleSafe( NS_USER, $record->user_name );
 637+ }
635638
636639 return Html::openElement( 'h3', array( 'class' => $class) )
637640 . Html::element( 'span', array( 'class' => 'icon' ) )
638 - . Linker::link( Title::newFromText( $link ), $name )
 641+ . Linker::link( $title, $name )
639642 . Html::element( 'span',
640643 array( 'class' => 'result' ),
641644 wfMessage( $message, $gender, $extra )->text()

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r109833AFT5 feedback page - adding HTML classes for the designers, and making the us...gregchiasson17:00, 23 January 2012

Comments

#Comment by Catrope (talk | contribs)   17:27, 1 February 2012
-		. Linker::link( Title::newFromText( $link ), $name )
+		. Linker::link( $title, $name )

You will still need to escape the second argument to link().

OK otherwise.

#Comment by Gregchiasson (talk | contribs)   18:02, 1 February 2012

$name is being fed through htmlspecialchars() already. Is there additional escaping that should be done?

#Comment by Catrope (talk | contribs)   18:49, 1 February 2012

D'oh, I'm blind. This is fine.

Status & tagging log