r105717 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105716‎ | r105717 | r105718 >
Date:20:59, 9 December 2011
Author:gregchiasson
Status:ok (Comments)
Tags:
Comment:
Escape all the unescaped text on AFTv5 feedback page.
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php
@@ -57,6 +57,7 @@
5858
5959 $where['af_page_id'] = $pageId;
6060
 61+ // TODO: Not this.
6162 return $dbr->selectField(
6263 array( 'aft_article_feedback' ),
6364 array( 'COUNT(*) AS count' ),
@@ -170,7 +171,7 @@
171172 protected function renderFeedback( $record ) {
172173 $id = $record[0]->af_id;
173174 $rv = "<div class='aft5-feedback'><p>"
174 - .wfMsg( 'articlefeedbackv5-form-header', $id, $record[0]->af_created )
 175+ .wfMessage( 'articlefeedbackv5-form-header', $id, $record[0]->af_created )->escaped()
175176 .'</p>';
176177 switch( $record[0]->af_bucket_id ) {
177178 case 1: $rv .= $this->renderBucket1( $record ); break;
@@ -182,63 +183,67 @@
183184 default: $rv .= $this->renderNoBucket( $record ); break;
184185 }
185186 $rv .= "<p>"
186 - .wfMsg( 'articlefeedbackv5-form-optionid', $record[0]->af_bucket_id )
 187+ .wfMessage( 'articlefeedbackv5-form-optionid', $record[0]->af_bucket_id )->escaped()
187188 ." | "
188189 ."<a href='#' class='aft5-hide-link' id='aft5-hide-link-$id'>"
189 - .wfMsg( 'articlefeedbackv5-form-hide', $record[0]->af_hide_count )
 190+ .wfMessage( 'articlefeedbackv5-form-hide', $record[0]->af_hide_count )->escaped()
190191 .'</a> | '
 192+//204
191193 ."<a href='#' class='aft5-abuse-link' id='aft5-abuse-link-$id'>"
192 - .wfMsg( 'articlefeedbackv5-form-abuse', $record[0]->af_abuse_count )
 194+ .wfMessage( 'articlefeedbackv5-form-abuse', $record[0]->af_abuse_count )->escaped()
193195 ."</a></p></div><hr>";
194196 return $rv;
195197 }
196198
197199 private function renderBucket1( $record ) {
198 - $name = $record[0]->user_name;
 200+ $name = htmlspecialchars( $record[0]->user_name );
199201 if( $record['found']->aa_response_boolean ) {
200 - $found = wfMsg(
 202+ $found = wfMessage(
201203 'articlefeedbackv5-form1-header-found',
202204 $name
203 - );
 205+ )->escaped();
204206 } else {
205 - $found = wfMsg(
 207+ $found = wfMessage(
206208 'articlefeedbackv5-form1-header-not-found',
207209 $name
208 - );
209 -
 210+ )->escaped();
210211 }
211212 return "$found
212 - <blockquote>".$record['comment']->aa_response_text
 213+ <blockquote>".htmlspecialchars( $record['comment']->aa_response_text )
213214 .'</blockquote>';
214215 }
215216
216217 private function renderBucket2( $record ) {
217 - $name = $record[0]->user_name;
218 - $type = $record['tag']->afo_name;
219 - return wfMsg( 'articlefeedbackv5-form2-header', $name, $type )
220 - .'<blockquote>'.$record['comment']->aa_response_text
 218+ $name = htmlspecialchars( $record[0]->user_name );
 219+ $type = htmlspecialchars( $record['tag']->afo_name );
 220+ return wfMessage( 'articlefeedbackv5-form2-header', $name, $type )->escaped()
 221+ .'<blockquote>'.htmlspecialchars( $record['comment']->aa_response_text )
221222 .'</blockquote>';
222223 }
223224
224225 private function renderBucket3( $record ) {
225 - $name = $record[0]->user_name;
226 - $rating = $record['rating']->aa_response_rating;
227 - return wfMsg( 'articlefeedbackv5-form3-header', $name, $rating )
228 - .'<blockquote>'.$record['comment']->aa_response_text
 226+ $name = htmlspecialchars( $record[0]->user_name );
 227+ $rating = htmlspecialchars( $record['rating']->aa_response_rating );
 228+ return wfMessage( 'articlefeedbackv5-form3-header', $name, $rating )->escaped()
 229+ .'<blockquote>'.htmlspecialchars( $record['comment']->aa_response_text )
229230 .'</blockquote>';
230231 }
231232
232233 private function renderBucket4( $record ) {
233 - return wfMsg( 'articlefeedbackv5-form4-header' );
 234+ return wfMessage( 'articlefeedbackv5-form4-header' )->escaped();
234235 }
235236
236237 private function renderBucket5( $record ) {
237 - $name = $record[0]->user_name;
238 - $rv = wfMsg( 'articlefeedbackv5-form5-header', $name );
 238+ $name = htmlspecialchars( $record[0]->user_name );
 239+ $rv = wfMessage( 'articlefeedbackv5-form5-header', $name )->escaped();
239240 $rv .= '<ul>';
240241 foreach( $record as $key => $answer ) {
241242 if( $answer->afi_data_type == 'rating' && $key != '0' ) {
242 - $rv .= "<li>".$answer->afi_name.': '.$answer->aa_response_rating."</li>";
 243+ $rv .= "<li>"
 244+ .htmlspecialchars( $answer->afi_name )
 245+ .': '
 246+ .htmlspecialchars( $answer->aa_response_rating )
 247+ ."</li>";
243248 }
244249 }
245250 $rv .= "</ul>";
@@ -252,11 +257,11 @@
253258 }
254259
255260 private function renderNoBucket( $record ) {
256 - return wfMsg( 'articlefeedbackv5-form-invalid' );
 261+ return wfMessage( 'articlefeedbackv5-form-invalid' )->escaped();
257262 }
258263
259264 private function renderBucket6( $record ) {
260 - return wfMsg( 'articlefeedbackv5-form-not-shown' );
 265+ return wfMessage( 'articlefeedbackv5-form-not-shown' )->escaped();
261266 }
262267
263268 /**

Comments

#Comment by Catrope (talk | contribs)   20:32, 12 December 2011
+//204

?

#Comment by Krinkle (talk | contribs)   20:51, 12 December 2011
+		// TODO: Not this.

Status & tagging log