r75841 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75840‎ | r75841 | r75842 >
Date:23:08, 1 November 2010
Author:mah
Status:ok
Tags:
Comment:
* Add note about security measures we're taking.
* Protect against possibility where rss member in renderRss is not an
object.
* Move user-agent string up to a define().
* Remove use of $rssTemp var in renderItem() by inlining code.
Modified paths:
  • /trunk/extensions/RSS/RSS.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RSS/RSS.php
@@ -18,6 +18,8 @@
1919 die( "This is not a valid entry point.\n" );
2020 }
2121
 22+define( 'RSS_USER_AGENT', 'MediaWikiRSS/0.01 (+http://www.mediawiki.org/wiki/Extension:RSS) / MediaWiki RSS extension' );
 23+
2224 // Extension credits that will show up on Special:Version
2325 $wgExtensionCredits['parserhook'][] = array(
2426 'name' => 'RSS feed',
@@ -90,7 +92,7 @@
9193 $status = $rss->fetch();
9294
9395 # Check for errors.
94 - if ( $status === false || !is_array( $rss->rss->items ) )
 96+ if ( $status === false || !is_object( $rss->rss ) || !is_array( $rss->rss->items ) )
9597 return wfMsg( 'rss-empty', $input );
9698
9799 if ( isset( $rss->ERROR ) )
@@ -179,7 +181,7 @@
180182 global $wgRSSDetectEncoding, $wgRSSUseGzip;
181183
182184 if ( !isset( $this->url ) ) {
183 - wfDebugLog( 'RSS: fetch called without a URL!' );
 185+ wfDebugLog( 'RSS', 'Fetch called without a URL!' );
184186 return false;
185187 }
186188
@@ -259,7 +261,7 @@
260262
261263 $client =
262264 HttpRequest::factory( $this->url, array( 'timeout' => $wgRSSFetchTimeout ) );
263 - $client->setUserAgent( 'MediaWikiRSS/0.01 (+http://www.mediawiki.org/wiki/Extension:RSS) / MediaWiki RSS extension' );
 265+ $client->setUserAgent( RSS_USER_AGENT );
264266 /* $client->use_gzip = $wgRSSUseGzip; */
265267 if ( is_array( $headers ) && count( $headers ) > 0 ) {
266268 foreach ( $headers as $h ) {
@@ -331,8 +333,7 @@
332334 $rendered[] = $part;
333335 }
334336 }
335 - $rssTemp = implode( " | ", $rendered );
336 - $output .= $parser->recursiveTagParse( $rssTemp, $frame );
 337+ $output .= $parser->recursiveTagParse( implode( " | ", $rendered ), $frame );
337338 }
338339 return $output;
339340 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r75842Add missing note about security re r75841mah23:09, 1 November 2010

Status & tagging log