r105654 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105653‎ | r105654 | r105655 >
Date:05:54, 9 December 2011
Author:tstarling
Status:ok (Comments)
Tags:
Comment:
Fixes for r102295:
* Rename getDiffText to getDiffLink since that's what it actually gets. Fix associated variable names.
* Use Html::element() not Html::rawElement() when escaping is desired.
Modified paths:
  • /trunk/phase3/includes/FeedUtils.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/FeedUtils.php
@@ -131,7 +131,7 @@
132132
133133 if ( $wgFeedDiffCutoff <= 0 || ( strlen( $diffText ) > $wgFeedDiffCutoff ) ) {
134134 // Omit large diffs
135 - $diffText = self::getDiffText( $title, $newid, $oldid);
 135+ $diffText = self::getDiffLink( $title, $newid, $oldid );
136136 } elseif ( $diffText === false ) {
137137 // Error in diff engine, probably a missing revision
138138 $diffText = "<p>Can't load revision $newid</p>";
@@ -150,7 +150,7 @@
151151 }
152152 if ( $wgFeedDiffCutoff <= 0 || strlen( $newtext ) > $wgFeedDiffCutoff ) {
153153 // Omit large new page diffs, bug 29110
154 - $diffText = self::getDiffText( $title, $newid );
 154+ $diffText = self::getDiffLink( $title, $newid );
155155 } else {
156156 $diffText = '<p><b>' . wfMsg( 'newpage' ) . '</b></p>' .
157157 '<div>' . nl2br( htmlspecialchars( $newtext ) ) . '</div>';
@@ -170,17 +170,16 @@
171171 * @param $newid Integer newid for this diff
172172 * @param $oldid Integer|null oldid for the diff. Null means it is a new article
173173 */
174 - protected static function getDiffText( Title $title, $newid, $oldid = null ) {
 174+ protected static function getDiffLink( Title $title, $newid, $oldid = null ) {
175175 $queryParameters = ($oldid == null)
176176 ? "diff={$newid}"
177177 : "diff={$newid}&oldid={$oldid}" ;
178 - $diffLink = $title->escapeFullUrl( $queryParameters );
 178+ $diffUrl = $title->escapeFullUrl( $queryParameters );
179179
180 - $diffText = Html::RawElement( 'a', array( 'href' => $diffLink ),
181 - htmlspecialchars( wfMsgForContent( 'showdiff' ) )
182 - );
 180+ $diffLink = Html::element( 'a', array( 'href' => $diffUrl ),
 181+ wfMsgForContent( 'showdiff' ) );
183182
184 - return $diffText;
 183+ return $diffLink;
185184 }
186185
187186 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r105662Fix for r102295 per CR r105654: don't double-escape the URLtstarling09:32, 9 December 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r102295bug 29110 - $wgFeedDiffCutoff doesn't affect new pages...hashar16:12, 7 November 2011

Comments

#Comment by Nikerabbit (talk | contribs)   08:47, 9 December 2011

Isn't $diffUrl escaped twice (now and before)?

#Comment by Tim Starling (talk | contribs)   09:32, 9 December 2011

Yes, well caught. Fixed in r105662.

Status & tagging log