r114390 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114389‎ | r114390 | r114391 >
Date:18:40, 21 March 2012
Author:catrope
Status:ok
Tags:
Comment:
Revert r111347, r111348, r111350, r111351, r111515, r111816, r112243, r112251, r112308, r112314, r112315, r112465, r112467, r112709, r113297, r113508, r113510, r113524, r113546, r114168. Unreviewed revisions in the RSS extension and their dependencies.

All of these revisions are tagged with 'gerritmigration' and will be resubmitted into Gerrit after the Gerrit switchover. See also http://lists.wikimedia.org/pipermail/wikitech-l/2012-March/059124.html
Modified paths:
  • /trunk/extensions/RSS/RELEASE-NOTES (modified) (history)
  • /trunk/extensions/RSS/RSS.i18n.php (modified) (history)
  • /trunk/extensions/RSS/RSS.php (modified) (history)
  • /trunk/extensions/RSS/RSSData.php (modified) (history)
  • /trunk/extensions/RSS/RSSHooks.php (modified) (history)
  • /trunk/extensions/RSS/RSSParser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RSS/RSSHooks.php
@@ -1,7 +1,6 @@
22 <?php
33
44 class RSSHooks {
5 -
65 /**
76 * Tell the parser how to handle <rss> elements
87 * @param $parser Parser Object
@@ -20,51 +19,24 @@
2120 * @param $parser Parser
2221 * @param $frame PPFrame parser context
2322 */
24 - static function renderRss( $input, array $args, Parser $parser, PPFrame $frame ) {
25 - global $wgRSSCacheAge, $wgRSSCacheCompare, $wgRSSNamespaces,
26 - $wgRSSUrlWhitelist,$wgRSSAllowedFeeds;
 23+ static function renderRss( $input, $args, $parser, $frame ) {
 24+ global $wgRSSCacheAge, $wgRSSCacheCompare, $wgRSSNamespaces, $wgRSSAllowedFeeds;
2725
2826 if ( is_array( $wgRSSNamespaces ) && count( $wgRSSNamespaces ) ) {
2927 $ns = $parser->getTitle()->getNamespace();
3028 $checkNS = array_flip( $wgRSSNamespaces );
3129
3230 if( !isset( $checkNS[$ns] ) ) {
33 - return RSSUtils::RSSError( 'rss-ns-permission' );
 31+ return wfMsg( 'rss-ns-permission' );
3432 }
3533 }
3634
37 - switch ( true ) {
38 -
39 - case ( isset( $wgRSSAllowedFeeds ) ):
40 - return RSSUtils::RSSError( 'rss-deprecated-wgrssallowedfeeds-found' );
41 - break;
42 -
43 - # disallow because there is no whitelist or empty whitelist
44 - case ( !isset( $wgRSSUrlWhitelist )
45 - || !is_array( $wgRSSUrlWhitelist )
46 - || ( count( $wgRSSUrlWhitelist ) === 0 ) ):
47 - return RSSUtils::RSSError( 'rss-empty-whitelist',
48 - $input
49 - );
50 - break;
51 -
52 - # allow
53 - case ( in_array( "*", $wgRSSUrlWhitelist ) ):
54 - case ( in_array( $input, $wgRSSUrlWhitelist ) ):
55 - break;
56 -
57 - # otherwise disallow
58 - case ( !in_array( $input, $wgRSSUrlWhitelist ) ):
59 - default:
60 - $listOfAllowed = $parser->getFunctionLang()->listToText( $wgRSSUrlWhitelist );
61 - $numberAllowed = $parser->getFunctionLang()->formatNum( count( $wgRSSUrlWhitelist ) );
62 - return RSSUtils::RSSError( 'rss-url-is-not-whitelisted',
63 - array( $input, $listOfAllowed, $numberAllowed )
64 - );
 35+ if ( count( $wgRSSAllowedFeeds ) && !in_array( $input, $wgRSSAllowedFeeds ) ) {
 36+ return wfMsg( 'rss-url-permission' );
6537 }
66 -
 38+
6739 if ( !Http::isValidURI( $input ) ) {
68 - return RSSUtils::RSSError( 'rss-invalid-url', htmlspecialchars( $input ) );
 40+ return wfMsg( 'rss-invalid-url', htmlspecialchars( $input ) );
6941 }
7042 if ( $wgRSSCacheCompare ) {
7143 $timeout = $wgRSSCacheCompare;
@@ -84,10 +56,9 @@
8557 }
8658
8759 if ( !is_object( $rss->rss ) || !is_array( $rss->rss->items ) ) {
88 - return RSSUtils::RSSError( 'rss-empty', htmlspecialchars( $input ) );
 60+ return wfMsg( 'rss-empty', htmlspecialchars( $input ) );
8961 }
9062
9163 return $rss->renderFeed( $parser, $frame );
9264 }
93 -
9465 }
Index: trunk/extensions/RSS/RELEASE-NOTES
@@ -2,6 +2,8 @@
33 http://www.mediawiki.org/wiki/Extension:RSS
44
55 === TO DO ===
 6+* bug 30377 add a new parameter to limit the number of characters when rendering
 7+ the channel item <description>
68 * set an upper default limit for HttpRequest request size when fetching feeds
79 doing a HEAD request first to ask for the size but that value may not be
810 available. Check how much data is returned as its coming back
@@ -10,57 +12,9 @@
1113 coming in. Then you could abort cleanly once it's gotten too much
1214 (otherwise using the defaults - PHP will abort the entire program when your
1315 memory usage gets too high)
 16+* bug 30028 "Error parsing XML for RSS" - improve and harden Extension:RSS when
 17+ parsing differently flavoured RSS feeds
1418
15 -=== Version 2.12 2012-03-07 ===
16 -* bug fix 34763 "RSS feed items (HTML) are not rendered as HTML but htmlescaped"
17 -* regression bug 30377 "Add a new parameter to limit the number of characters
18 - when rendering the channel item <description>". Feed item string length
19 - limitation is difficult when we allow HTML <a> or <img> tags, because a mere
20 - content-unaware limitation breaks (can break) tags which results in disastrous
21 - rendering results.
22 -
23 -=== Version 2.11 2012-02-29 ===
24 -* function name typo correction
25 -
26 -=== Version 2.10 2012-02-27 ===
27 -* final solution of bug 30028 "Error parsing XML for RSS" - improve and harden
28 - Extension:RSS when parsing differently flavoured RSS feeds and ATOM feeds
29 -* new parameter $wgRSSUrlNumberOfAllowedRedirects (default = 0)
30 - Some feed urls redirect. The new RSS version can deal with redirects,
31 - but it must be expressly enabled. For example, you can set
32 - $wgRSSUrlNumberOfAllowedRedirects = 1;
33 -
34 -=== Version 2.01 2012-02-24 ===
35 -* "summary" element of ATOM feed items are shown
36 - which is handled like "description" element of RSS
37 -* handling of basic HTML layout tags <p> <br> <b> <i> <u> <s> in item description
38 -
39 -=== Version 2.00 2012-02-24 ===
40 -* first version which can parse RSS and at least some ATOM feeds
41 - partial solution of bug 30028 "Error parsing XML for RSS" - improve and harden
42 - Extension:RSS when parsing differently flavoured RSS feeds and ATOM feeds
43 -
44 -=== Version 1.94 2012-02-23 ===
45 -* changed white list definition and behaviour:
46 -
47 - 1. changed the name from $wgRSSAllowedFeeds to $wgRSSUrlWhitelist
48 - 2. behaviour has been changed
49 -
50 - the new behaviour is:
51 - $wgRSSUrlWhitelist is empty by default. Since version 1.94 it must be
52 - expressly set to an array( list-of-comma-separated-allowed-RSS-urls-strings )
53 - or set to array( "*" ) if you want to allow any url
54 -
55 - the old behaviour was:
56 - $wgRSSAllowedFeeds was empty by default and empty meant that every Url
57 - was allowed by default. This has been changed, see new behaviour.
58 -
59 -=== Version 1.92 2012-02-13 ===
60 -* added optional date= attribute and $wgRSSDateDefaultFormat parameter
61 -* added optional item-max-length= attribute and $wgRSSItemMaxLength parameter
62 - fixes bug 30377 add a new parameter to limit the number of characters when
63 - rendering the channel item <description>
64 -
6519 === Version 1.90 2011-08-15 ===
6620 * removed parsing of each single channel subelement (item)
6721 * only the finally constructed feed is sent to the recursive parser:
Index: trunk/extensions/RSS/RSSData.php
@@ -15,14 +15,8 @@
1616 return;
1717 }
1818 $xpath = new DOMXPath( $xml );
19 -
20 - // namespace-safe method to find all elements
21 - $items = $xpath->query( "//*[local-name() = 'item']" );
 19+ $items = $xpath->query( '/rss/channel/item' );
2220
23 - if ( $items->length == 0 ) {
24 - $items = $xpath->query( "//*[local-name() = 'entry']" );
25 - }
26 -
2721 if( $items->length !== 0 ) {
2822 foreach ( $items as $item ) {
2923 $bit = array();
@@ -43,7 +37,7 @@
4438 $this->items[] = $bit;
4539 }
4640 } else {
47 - $this->error = 'No RSS//ATOM items found.';
 41+ $this->error = 'No RSS items found.';
4842 return;
4943 }
5044 }
@@ -58,16 +52,18 @@
5953 * @param $n String: name of the element we have
6054 * @return String Name to map it to
6155 */
62 - protected function rssTokenToName( $name ) {
63 - switch( $name ) {
 56+ protected function rssTokenToName( $n ) {
 57+ switch( $n ) {
6458 case 'dc:date':
 59+ return 'date';
 60+ # parse "2010-10-18T18:07:00Z"
6561 case 'pubDate':
66 - case 'updated':
6762 return 'date';
 63+ # parse RFC date
6864 case 'dc:creator':
6965 return 'author';
70 - case 'summary':
71 - return 'description';
 66+ case 'title':
 67+ return 'title';
7268 case 'content:encoded':
7369 return 'encodedContent';
7470
@@ -80,8 +76,9 @@
8177 case 'comments':
8278 case 'category':
8379 return null;
 80+
8481 default:
85 - return $name;
 82+ return $n;
8683 }
8784 }
8885 }
\ No newline at end of file
Index: trunk/extensions/RSS/RSSParser.php
@@ -2,8 +2,6 @@
33
44 class RSSParser {
55 protected $maxheads = 32;
6 - protected $date = "Y-m-d H:i:s";
7 - protected $ItemMaxLength = 200;
86 protected $reversed = false;
97 protected $highlight = array();
108 protected $filter = array();
@@ -39,8 +37,6 @@
4038 * and return an object that can produce rendered output.
4139 */
4240 function __construct( $url, $args ) {
43 - global $wgRSSDateDefaultFormat,$wgRSSItemMaxLength;
44 -
4541 $this->url = $url;
4642
4743 # Get max number of headlines from argument-array
@@ -54,13 +50,11 @@
5551 }
5652
5753 # Get date format from argument array
58 - # or use a default value
 54+ # FIXME: not used yet
5955 if ( isset( $args['date'] ) ) {
6056 $this->date = $args['date'];
61 - } elseif ( isset( $wgRSSDateDefaultFormat ) ) {
62 - $this->date = $wgRSSDateDefaultFormat;
6357 }
64 -
 58+
6559 # Get highlight terms from argument array
6660 if ( isset( $args['highlight'] ) ) {
6761 # mapping to lowercase here so the regex can be case insensitive below.
@@ -72,13 +66,6 @@
7367 $this->filter = self::explodeOnSpaces( $args['filter'] );
7468 }
7569
76 - # Get a maximal length for item texts
77 - if ( isset( $args['item-max-length'] ) ) {
78 - $this->ItemMaxLength = $args['item-max-length'];
79 - } elseif ( is_numeric( $wgRSSItemMaxLength ) ) {
80 - $this->ItemMaxLength = $wgRSSItemMaxLength;
81 - }
82 -
8370 if ( isset( $args['filterout'] ) ) {
8471 $this->filterOut = self::explodeOnSpaces( $args['filterout'] );
8572 }
@@ -218,8 +205,7 @@
219206 * @return Status object
220207 */
221208 protected function fetchRemote( $key, array $headers = array()) {
222 - global $wgRSSFetchTimeout, $wgRSSUserAgent, $wgRSSProxy,
223 - $wgRSSUrlNumberOfAllowedRedirects;
 209+ global $wgRSSFetchTimeout, $wgRSSUserAgent, $wgRSSProxy;
224210
225211 if ( $this->etag ) {
226212 wfDebugLog( 'RSS', 'Used etag: ' . $this->etag );
@@ -231,71 +217,12 @@
232218 $headers['If-Modified-Since'] = $lm;
233219 }
234220
235 - /**
236 - * 'noProxy' can conditionally be set as shown in the commented
237 - * example below; in HttpRequest 'noProxy' takes precedence over
238 - * any value of 'proxy' and disables the use of a proxy.
239 - *
240 - * This is useful if you run the wiki in an intranet and need to
241 - * access external feed urls through a proxy but internal feed
242 - * urls must be accessed without a proxy.
243 - *
244 - * The general handling of such cases will be subject of a
245 - * forthcoming version.
246 - */
 221+ $client = HttpRequest::factory( $this->url, array(
 222+ 'timeout' => $wgRSSFetchTimeout,
 223+ 'proxy' => $wgRSSProxy
247224
248 - $url = $this->url;
249 - $noProxy = !isset( $wgRSSProxy );
250 -
251 - // Example for disabling proxy use for certain urls
252 - // $noProxy = preg_match( '!\.internal\.example\.com$!i', parse_url( $url, PHP_URL_HOST ) );
253 -
254 - /**
255 - * Copied from HttpFunctions.php
256 - * Perform an HTTP request
257 - *
258 - * @param $method String: HTTP method. Usually GET/POST
259 - * @param $url String: full URL to act on. If protocol-relative, will be expanded to an http:// URL
260 - * @param $options Array: options to pass to MWHttpRequest object.
261 - * Possible keys for the array:
262 - * - timeout Timeout length in seconds
263 - * - postData An array of key-value pairs or a url-encoded form data
264 - * - proxy The proxy to use.
265 - * Otherwise it will use $wgHTTPProxy (if set)
266 - * Otherwise it will use the environment variable "http_proxy" (if set)
267 - * - noProxy Don't use any proxy at all. Takes precedence over proxy value(s).
268 - * - sslVerifyHost (curl only) Verify hostname against certificate
269 - * - sslVerifyCert (curl only) Verify SSL certificate
270 - * - caInfo (curl only) Provide CA information
271 - * - maxRedirects Maximum number of redirects to follow (defaults to 5)
272 - * - followRedirects Whether to follow redirects (defaults to false).
273 - * Note: this should only be used when the target URL is trusted,
274 - * to avoid attacks on intranet services accessible by HTTP.
275 - * - userAgent A user agent, if you want to override the default
276 - * MediaWiki/$wgVersion
277 - * @return Mixed: (bool)false on failure or a string on success
278 - */
279 -
280 - if ( isset( $wgRSSUrlNumberOfAllowedRedirects )
281 - && is_numeric( $wgRSSUrlNumberOfAllowedRedirects ) ) {
282 - $maxRedirects = $wgRSSUrlNumberOfAllowedRedirects;
283 - } else {
284 - $maxRedirects = 0;
285 - }
286 -
287 - // we set followRedirects intentionally to true to see error messages
288 - // in cases where the maximum number of redirects is reached
289 - $client = HttpRequest::factory( $url,
290 - array(
291 - 'timeout' => $wgRSSFetchTimeout,
292 - 'followRedirects' => true,
293 - 'maxRedirects' => $maxRedirects,
294 - 'proxy' => $wgRSSProxy,
295 - 'noProxy' => $noProxy,
296 - 'userAgent' => $wgRSSUserAgent,
297 - )
298 - );
299 -
 225+ ) );
 226+ $client->setUserAgent( $wgRSSUserAgent );
300227 foreach ( $headers as $header => $value ) {
301228 $client->setHeader( $header, $value );
302229 }
@@ -312,14 +239,6 @@
313240 return $ret;
314241 }
315242
316 - function sandboxParse($wikiText) {
317 - global $wgTitle, $wgUser;
318 - $myParser = new Parser();
319 - $myParserOptions = ParserOptions::newFromUser($wgUser);
320 - $result = $myParser->parse($wikiText, $wgTitle, $myParserOptions);
321 - return $result->getText();
322 - }
323 -
324243 /**
325244 * Render the entire feed so that each item is passed to the
326245 * template which the MediaWiki then displays.
@@ -328,7 +247,7 @@
329248 * @param $frame the frame param to pass to recursiveTagParse()
330249 */
331250 function renderFeed( $parser, $frame ) {
332 -
 251+
333252 $renderedFeed = '';
334253
335254 if ( isset( $this->itemTemplate ) && isset( $parser ) && isset( $frame ) ) {
@@ -344,16 +263,15 @@
345264 }
346265
347266 if ( $this->canDisplay( $item ) ) {
348 - $renderedFeed .= $this->renderItem( $item, $parser ) . "\n";
 267+ $renderedFeed .= $this->renderItem( $item ) . "\n";
349268 $headcnt++;
350269 }
351270 }
352271
353 - $renderedFeed = $this->sandboxParse( $renderedFeed );
 272+ $renderedFeed = $parser->recursiveTagParse( $renderedFeed, $frame );
354273
355 - }
356 -
357 - $parser->addTrackingCategory( 'rss-tracking-category' );
 274+ }
 275+
358276 return $renderedFeed;
359277 }
360278
@@ -362,7 +280,7 @@
363281 *
364282 * @param $item Array: an array produced by RSSData where keys are the names of the RSS elements
365283 */
366 - protected function renderItem( $item, $parser ) {
 284+ protected function renderItem( $item ) {
367285
368286 $renderedItem = $this->itemTemplate;
369287
@@ -371,38 +289,14 @@
372290 // and that means bad RSS with stuff like
373291 // <description><script>alert("hi")</script></description> will find its
374292 // rogue <script> tags neutered.
375 - // use the overloaded multi byte wrapper functions in GlobalFunctions.php
376293
377294 foreach ( array_keys( $item ) as $info ) {
378 - switch ( $info ) {
379 - // ATOM <id> elements and RSS <link> elements are item link urls
380 - case 'id':
381 - $txt = $this->sanitizeUrl( $item['id'] );
382 - $renderedItem = str_replace( '{{{link}}}', $txt, $renderedItem );
383 - break;
384 - case 'link':
385 - if ( !isset( $item['id'] ) ) {
386 - $txt = $this->sanitizeUrl( $item['link'] );
387 - }
388 - $renderedItem = str_replace( '{{{link}}}', $txt, $renderedItem );
389 - break;
390 - case 'date':
391 - $tempTimezone = date_default_timezone_get();
392 - date_default_timezone_set( 'UTC' );
393 - $txt = date( $this->date, strtotime( $this->escapeTemplateParameter( $item['date'] ) ) );
394 - date_default_timezone_set( $tempTimezone );
395 - $renderedItem = str_replace( '{{{date}}}', $txt, $renderedItem );
396 - break;
397 - default:
398 - $str = $this->escapeTemplateParameter( $item[$info] );
399 - /***
400 - if ( mb_strlen( $str ) > $this->ItemMaxLength ) {
401 - $str = mb_substr( $str, 0, $this->ItemMaxLength ) . " ...";
402 - }
403 - ***/
404 - $txt = $this->highlightTerms( $str );
405 - $renderedItem = str_replace( '{{{' . $info . '}}}', $parser->insertStripItem( $str ), $renderedItem );
 295+ if ( $info != 'link' ) {
 296+ $txt = $this->highlightTerms( $this->escapeTemplateParameter( $item[ $info ] ) );
 297+ } else {
 298+ $txt = $this->sanitizeUrl( $item[ $info ] );
406299 }
 300+ $renderedItem = str_replace( '{{{' . $info . '}}}', $txt, $renderedItem );
407301 }
408302
409303 // nullify all remaining info items in the template
@@ -440,65 +334,18 @@
441335
442336 /**
443337 * Sanitize user input for inclusion as a template parameter.
444 - *
445338 * Unlike in wfEscapeWikiText() as of r77127, this escapes }} in addition
446339 * to the other kinds of markup, to avoid user input ending a template
447340 * invocation.
448 - *
449 - * If you want to allow clickable link Urls (HTML <a> tag) in RSS feeds:
450 - * $wgRSSAllowLinkTag = true;
451 - *
452 - * If you want to allow images (HTML <img> tag) in RSS feeds:
453 - * $wgAllowImageTag = true;
454 - *
455341 */
456342 protected function escapeTemplateParameter( $text ) {
457 - global $wgRSSAllowLinkTag, $wgAllowImageTag;
458 -
459 - if ( isset( $wgRSSAllowLinkTag ) && $wgRSSAllowLinkTag ) {
460 - $extra = array( "a" );
461 - } else {
462 - $extra = array();
463 - }
464 -
465 - if ( ( isset( $wgRSSAllowLinkTag ) && $wgRSSAllowLinkTag )
466 - || ( isset( $wgAllowImageTag ) && $wgAllowImageTag ) ) {
467 -
468 - $ret = Sanitizer::removeHTMLtags( $text, null, array(), $extra, array( "iframe" ) );
469 -
470 - } else { // use the old escape method for a while
471 -
472 - $text = str_replace(
473 - array( '[', '|', ']', '\'', 'ISBN ',
474 - 'RFC ', '://', "\n=", '{{', '}}',
475 - ),
476 - array( '&#91;', '&#124;', '&#93;', '&#39;', 'ISBN&#32;',
477 - 'RFC&#32;', '&#58;//', "\n&#61;", '&#123;&#123;', '&#125;&#125;',
478 - ),
479 - htmlspecialchars( str_replace( "\n", "", $text ) )
480 - );
481 -
482 - // keep some basic layout tags
483 - $ret = str_replace(
484 - array( '&lt;p&gt;', '&lt;/p&gt;',
485 - '&lt;br/&gt;', '&lt;br&gt;', '&lt;/br&gt;',
486 - '&lt;b&gt;', '&lt;/b&gt;',
487 - '&lt;i&gt;', '&lt;/i&gt;',
488 - '&lt;u&gt;', '&lt;/u&gt;',
489 - '&lt;s&gt;', '&lt;/s&gt;',
490 - ),
491 - array( "", "<br/>",
492 - "<br/>", "<br/>", "<br/>",
493 - "'''", "'''",
494 - "''", "''",
495 - "<u>", "</u>",
496 - "<s>", "</s>",
497 - ),
498 - $text
499 - );
500 - }
501 -
502 - return $ret;
 343+ return str_replace(
 344+ array( '[', '|', ']', '\'', 'ISBN ',
 345+ 'RFC ', '://', "\n=", '{{', '}}' ),
 346+ array( '&#91;', '&#124;', '&#93;', '&#39;', 'ISBN&#32;',
 347+ 'RFC&#32;', '&#58;//', "\n&#61;", '&#123;&#123;', '&#125;&#125;' ),
 348+ htmlspecialchars( $text )
 349+ );
503350 }
504351
505352 /**
@@ -574,8 +421,8 @@
575422 *
576423 * @param $text String: the text to examine
577424 * @param $filterType String: "filterOut" to check for matches in the
578 - * filterOut member list.
579 - * Otherwise, uses the filter member list.
 425+ * filterOut member list.
 426+ * Otherwise, uses the filter member list.
580427 * @return Boolean: decision to filter or not.
581428 */
582429 protected function filter( $text, $filterType ) {
@@ -650,25 +497,3 @@
651498 return sprintf( $styleStart, $bgcolor[$index], $color[$index] ) . $match[0] . $styleEnd;
652499 }
653500 }
654 -
655 -class RSSUtils {
656 -
657 - /**
658 - * Output an error message, all wraped up nicely.
659 - * @param String $errorMessageName The system message that this error is
660 - * @param String|Array $param Error parameter (or parameters)
661 - * @return String Html that is the error.
662 - */
663 - public static function RSSError( $errorMessageName, $param = false ) {
664 -
665 - // Anything from a parser tag should use Content lang for message,
666 - // since the cache doesn't vary by user language: do not use wfMsgForContent but wfMsgForContent
667 - // The ->parse() part makes everything safe from an escaping standpoint.
668 -
669 - return Html::rawElement( 'span', array( 'class' => 'error' ),
670 - "Extension:RSS -- Error: " . wfMessage( $errorMessageName )->inContentLanguage()->params( $param )->parse()
671 - );
672 -
673 - }
674 -
675 -}
Index: trunk/extensions/RSS/RSS.i18n.php
@@ -14,16 +14,13 @@
1515
1616 $messages['en'] = array(
1717 'rss-desc' => 'Displays RSS feeds on MediaWiki pages in a standard or in user-definable formats using template pages',
18 - 'rss-tracking-category' => 'Pages with RSS feeds',
1918 'rss-error' => 'Failed to load RSS feed from $1: $2',
2019 'rss-empty' => 'Failed to load RSS feed from $1!',
2120 'rss-fetch-nourl' => 'Fetch called without a URL!',
2221 'rss-invalid-url' => 'Not a valid URL: $1',
2322 'rss-parse-error' => 'Error parsing XML for RSS',
2423 'rss-ns-permission' => 'RSS is not allowed in this namespace',
25 - 'rss-url-is-not-whitelisted' => '"$1" is not in the whitelist of allowed feeds. {{PLURAL:$3|$2 is the only allowed feed|The allowed feeds are as follows: $2}}.',
26 - 'rss-empty-whitelist' => '"$1" is not in the whitelist of allowed feeds. There are no allowed feed URLs in the whitelist.',
27 - 'rss-deprecated-wgrssallowedfeeds-found' => 'The deprecated variable $wgRSSAllowedFeeds has been detected. Since RSS version 2.0 this variable has to be replaced by $wgRSSUrlWhitelist as described in the manual page Extension:RSS.',
 24+ 'rss-url-permission' => 'This URL is not allowed to be included',
2825 'rss-item' => '{{$1 | title = {{{title}}} | link = {{{link}}} | date = {{{date}}} | author = {{{author}}} | description = {{{description}}} }}',
2926 'rss-feed' => "<!-- the following are two alternative templates. The first is the basic default template for feeds -->; '''<span class='plainlinks'>[{{{link}}} {{{title}}}]</span>'''
3027 : {{{description}}}
@@ -35,7 +32,6 @@
3633 * @author Yekrats
3734 */
3835 $messages['qqq'] = array(
39 - 'rss-tracking-category' => 'The name of a category for all pages which use the &lt;rss&gt; parser extension tag. The category is automatically added unless the feature is disabled.',
4036 'rss-invalid-url' => '$1 is the invalid URL for the RSS feed',
4137 'rss-feed' => "; $1
4238 : ''not to be localised''
Index: trunk/extensions/RSS/RSS.php
@@ -4,7 +4,7 @@
55 *
66 * @file
77 * @ingroup Extensions
8 - * @version 2.15
 8+ * @version 1.90
99 * @author mutante, Daniel Kinzler, Rdb, Mafs, Thomas Gries, Alxndr, Chris Reigrut, K001
1010 * @author Kellan Elliott-McCrea <kellan@protest.net> -- author of MagpieRSS
1111 * @author Jeroen De Dauw
@@ -14,8 +14,6 @@
1515 * @link http://www.mediawiki.org/wiki/Extension:RSS Documentation
1616 */
1717
18 -define( "EXTENSION_RSS_VERSION", "2.15 20120319" );
19 -
2018 if ( !defined( 'MEDIAWIKI' ) ) {
2119 die( "This is not a valid entry point.\n" );
2220 }
@@ -28,7 +26,7 @@
2927 'Rdb', 'Mafs', 'Alxndr', 'Thomas Gries', 'Chris Reigrut',
3028 'K001', 'Jack Phoenix', 'Jeroen De Dauw', 'Mark A. Hershberger'
3129 ),
32 - 'version' => EXTENSION_RSS_VERSION,
 30+ 'version' => '1.90 20110815',
3331 'url' => 'https://www.mediawiki.org/wiki/Extension:RSS',
3432 'descriptionmsg' => 'rss-desc',
3533 );
@@ -38,63 +36,32 @@
3937 $wgExtensionMessagesFiles['RSS'] = $dir . 'RSS.i18n.php';
4038 $wgAutoloadClasses['RSSHooks'] = $dir . 'RSSHooks.php';
4139 $wgAutoloadClasses['RSSParser'] = $dir . 'RSSParser.php';
42 -$wgAutoloadClasses['RSSUtils'] = $dir . 'RSSParser.php';
4340 $wgAutoloadClasses['RSSData'] = $dir . 'RSSData.php';
4441
4542 $wgHooks['ParserFirstCallInit'][] = 'RSSHooks::parserInit';
4643
47 -// one hour
48 -$wgRSSCacheAge = 3600;
 44+ // one hour
 45+ $wgRSSCacheAge = 3600;
4946
5047 // Check cached content, if available, against remote.
5148 // $wgRSSCacheCompare should be set to false or a timeout
5249 // (less than $wgRSSCacheAge) after which a comparison will be made.
53 -// for debugging set $wgRSSCacheCompare = 1;
5450 $wgRSSCacheCompare = false;
5551
56 -// 15 second timeout
57 -$wgRSSFetchTimeout = 15;
 52+// 5 second timeout
 53+$wgRSSFetchTimeout = 5;
5854
5955 // Ignore the RSS tag in all but the namespaces listed here.
6056 // null (the default) means the <rss> tag can be used anywhere.
6157 $wgRSSNamespaces = null;
6258
63 -// Whitelist of allowed RSS Urls
64 -//
65 -// If there are items in the array, and the user supplied URL is not in the array,
66 -// the url will not be allowed
67 -//
68 -// Urls are case-sensitively tested against values in the array.
69 -// They must exactly match including any trailing "/" character.
70 -//
71 -// Warning: Allowing all urls (not setting a whitelist)
72 -// may be a security concern.
73 -//
74 -// an empty or non-existent array means: no whitelist defined
75 -// this is the default: an empty whitelist. No servers are allowed by default.
76 -$wgRSSUrlWhitelist = array();
 59+// URL whitelist of RSS Feeds:
 60+// if there are items in the array, and the used URL isn't in the array,
 61+// it will not be allowed (originally proposed in bug 27768)
 62+$wgRSSAllowedFeeds = array();
7763
78 -// include "*" if you expressly want to allow all urls (you should not do this)
79 -// $wgRSSUrlWhitelist = array( "*" );
80 -
81 -// Maximum number of redirects to follow (defaults to 0)
82 -// Note: this should only be used when the target URLs are trusted,
83 -// to avoid attacks on intranet services accessible by HTTP.
84 -$wgRSSUrlNumberOfAllowedRedirects = 0;
85 -
8664 // Agent to use for fetching feeds
87 -$wgRSSUserAgent = "MediaWikiRSS/" . strtok( EXTENSION_RSS_VERSION, " " ) . " (+http://www.mediawiki.org/wiki/Extension:RSS) / MediaWiki RSS extension";
 65+$wgRSSUserAgent = 'MediaWikiRSS/0.02 (+http://www.mediawiki.org/wiki/Extension:RSS) / MediaWiki RSS extension';
8866
8967 // Proxy server to use for fetching feeds
9068 $wgRSSProxy = false;
91 -
92 -// default date format of item publication dates see http://www.php.net/date
93 -$wgRSSDateDefaultFormat = "(Y-m-d H:i:s)";
94 -
95 -// limit the number of characters in the item description
96 -// or set to false for unlimited length.
97 -// THIS IS CURRENTLY NOT WORKING (bug 30377)
98 -$wgRSSItemMaxLength = false;
99 -
100 -// You can choose to allow active links in feed items; default: false
101 -$wgRSSAllowLinkTag = false;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r111347adding the long-wanted date format attribute. implemented a date format equal...wikinaut01:39, 13 February 2012
r111348follow-up r111347 : adding escapeTemplateParameter around the user supplied o...wikinaut01:49, 13 February 2012
r111350fix for bug30377 : add a new parameter to limit the number of characters when...wikinaut07:23, 13 February 2012
r111351follow-up r111350 . check if optional parameter isset and is_numeric, otherw...wikinaut07:36, 13 February 2012
r111515removed a wrong comment regarding PHP 5.3 function date_create_from_format, w...wikinaut00:11, 15 February 2012
r111816follow-up r111350 r111351 . switch replaced by if elseif construct.wikinaut07:35, 18 February 2012
r112243name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist. The wgRSS...wikinaut21:12, 23 February 2012
r112251increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too...wikinaut22:24, 23 February 2012
r112308v2.00 can parse ATOM feeds, at least some. This is a major improvement over p...wikinaut10:16, 24 February 2012
r112314v2.01 fixed ATOM summary element was forgotten to be parsed. Added handling o...wikinaut11:37, 24 February 2012
r112315improved code legibility function namespacePrefixedQuerywikinaut11:47, 24 February 2012
r112465fix for ultra bug 30028 . The RSS extension can parse RSS and ATOM feeds of d...wikinaut01:10, 27 February 2012
r112467removed superfluous code for setting userAgent since r112466wikinaut01:44, 27 February 2012
r112709function name typo correction. Version number updatewikinaut20:00, 29 February 2012
r113297fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlesca...wikinaut21:06, 7 March 2012
r113508add tracking category feature (enabled by default). Each page using this exte...wikinaut19:43, 9 March 2012
r113510follow up r113508 : escaped html tag brackets to make translaters happywikinaut19:50, 9 March 2012
r113524beautifying the tracking category namewikinaut21:03, 9 March 2012
r113546adding casts. better ?wikinaut23:28, 9 March 2012
r114168removed the redundant code for handling tracking categories. By using '-' for...wikinaut18:56, 19 March 2012

Status & tagging log