r87165 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87164‎ | r87165 | r87166 >
Date:15:12, 30 April 2011
Author:ialex
Status:resolved
Tags:
Comment:
Properly escape the ouput in action=credits (and in page footer), using wfMessage() to be able to replace some parameters before and some after
Modified paths:
  • /trunk/phase3/includes/actions/CreditsAction.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/actions/CreditsAction.php
@@ -89,7 +89,7 @@
9090 $d = '';
9191 $t = '';
9292 }
93 - return wfMsgExt( 'lastmodifiedatby', 'parsemag', $d, $t, self::userLink( $user ), $user->getName() );
 93+ return wfMessage( 'lastmodifiedatby', $d, $t )->rawParams( self::userLink( $user ) )->params( $user->getName() )->escaped();
9494 }
9595
9696 /**
@@ -110,7 +110,7 @@
111111 if ( $cnt > 0 && $contributors->count() > $cnt ) {
112112 $others_link = $this->othersLink();
113113 if ( !$showIfMax )
114 - return wfMsgExt( 'othercontribs', 'parsemag', $others_link, $contributors->count() );
 114+ return wfMessage( 'othercontribs' )->rawParams( $others_link )->params( $contributors->count() )->escaped();
115115 }
116116
117117 $real_names = array();
@@ -144,21 +144,15 @@
145145
146146 # "ThisSite user(s) A, B and C"
147147 if ( count( $user_names ) ) {
148 - $user = wfMsgExt(
149 - 'siteusers',
150 - 'parsemag',
151 - $wgLang->listToText( $user_names ), count( $user_names )
152 - );
 148+ $user = wfMessage( 'siteusers' )->rawParams( $wgLang->listToText( $user_names ) )->params(
 149+ count( $user_names ) )->escaped();
153150 } else {
154151 $user = false;
155152 }
156153
157154 if ( count( $anon_ips ) ) {
158 - $anon = wfMsgExt(
159 - 'anonusers',
160 - 'parsemag',
161 - $wgLang->listToText( $anon_ips ), count( $anon_ips )
162 - );
 155+ $anon = wfMessage( 'anonusers' )->rawParams( $wgLang->listToText( $anon_ips ) )->params(
 156+ $anon_ips )->escaped();
163157 } else {
164158 $anon = false;
165159 }
@@ -166,17 +160,16 @@
167161 # This is the big list, all mooshed together. We sift for blank strings
168162 $fulllist = array();
169163 foreach ( array( $real, $user, $anon, $others_link ) as $s ) {
170 - if ( $s ) {
 164+ if ( $s !== false ) {
171165 array_push( $fulllist, $s );
172166 }
173167 }
174168
175 - # Make the list into text...
176 - $creds = $wgLang->listToText( $fulllist );
177 -
 169+ $count = count( $fulllist );
178170 # "Based on work by ..."
179 - return strlen( $creds )
180 - ? wfMsgExt( 'othercontribs', 'parsemag', $creds, count( $fulllist ) )
 171+ return $count
 172+ ? wfMessage( 'othercontribs' )->rawParams(
 173+ $wgLang->listToText( $fulllist ) )->params( $count )->escaped()
181174 : '';
182175 }
183176
@@ -214,7 +207,7 @@
215208 if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() ) {
216209 return $link;
217210 } else {
218 - return wfMsgExt( 'siteuser', 'parsemag', $link, $user->getName() );
 211+ return wfMessage( 'siteuser' )->rawParams( $link )->params( $user->getName() )->escaped();
219212 }
220213 }
221214 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r87166I have no idea where that count() pass in r87165ialex15:14, 30 April 2011

Status & tagging log