2010-11-04 23:19:00 +00:00
|
|
|
<?php
|
2010-11-05 00:59:28 +00:00
|
|
|
|
2022-04-06 00:05:34 +00:00
|
|
|
namespace MediaWiki\Extension\RSS;
|
|
|
|
|
2023-09-16 20:01:20 +00:00
|
|
|
use MediaWiki\Hook\ParserFirstCallInitHook;
|
2024-06-10 18:17:47 +00:00
|
|
|
use MediaWiki\Parser\Parser;
|
2024-10-20 09:32:26 +00:00
|
|
|
use MediaWiki\Parser\PPFrame;
|
2024-01-05 20:23:30 +00:00
|
|
|
use MediaWiki\Status\Status;
|
2022-04-06 00:05:34 +00:00
|
|
|
use MWHttpRequest;
|
|
|
|
|
2023-09-16 20:01:20 +00:00
|
|
|
class Hooks implements ParserFirstCallInitHook {
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
|
2010-11-04 23:19:00 +00:00
|
|
|
/**
|
|
|
|
* Tell the parser how to handle <rss> elements
|
2017-10-14 15:23:24 +00:00
|
|
|
* @param Parser $parser Parser Object
|
2010-11-04 23:19:00 +00:00
|
|
|
*/
|
2023-09-16 20:01:20 +00:00
|
|
|
public function onParserFirstCallInit( $parser ) {
|
2017-05-20 21:41:06 +00:00
|
|
|
// Install parser hook for <rss> tags
|
|
|
|
$parser->setHook( 'rss', [ __CLASS__, 'renderRss' ] );
|
2010-11-04 23:19:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Static function wrapping RSSParser to handle rendering of RSS elements
|
2017-10-14 15:23:24 +00:00
|
|
|
* @param string $input text inside the tags.
|
|
|
|
* @param array $args value associative list of the element attributes and
|
2010-11-05 00:59:28 +00:00
|
|
|
* their values.
|
2017-10-14 15:23:24 +00:00
|
|
|
* @param Parser $parser
|
|
|
|
* @param PPFrame $frame parser context
|
2012-10-07 10:11:49 +00:00
|
|
|
* @return string
|
2010-11-04 23:19:00 +00:00
|
|
|
*/
|
2018-11-02 10:23:45 +00:00
|
|
|
public static function renderRss( $input, array $args, Parser $parser, PPFrame $frame ) {
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
global $wgRSSCacheAge, $wgRSSCacheCompare, $wgRSSNamespaces,
|
2024-03-11 21:44:41 +00:00
|
|
|
$wgRSSUrlWhitelist, $wgRSSAllowedFeeds;
|
2011-05-06 16:21:43 +00:00
|
|
|
|
2011-05-06 16:40:14 +00:00
|
|
|
if ( is_array( $wgRSSNamespaces ) && count( $wgRSSNamespaces ) ) {
|
2019-01-08 17:35:47 +00:00
|
|
|
$nsUsed = $parser->getTitle()->getNamespace();
|
|
|
|
$authorizedNamespace = array_flip( $wgRSSNamespaces );
|
2011-05-06 16:21:43 +00:00
|
|
|
|
2019-01-08 17:35:47 +00:00
|
|
|
if ( !isset( $authorizedNamespace[$nsUsed] ) ) {
|
2022-04-06 00:05:34 +00:00
|
|
|
return Utils::getErrorHtml( 'rss-ns-permission' );
|
2011-05-06 16:21:43 +00:00
|
|
|
}
|
|
|
|
}
|
2010-11-04 23:19:00 +00:00
|
|
|
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
if ( isset( $wgRSSAllowedFeeds ) ) {
|
2022-04-06 00:05:34 +00:00
|
|
|
return Utils::getErrorHtml( 'rss-deprecated-wgrssallowedfeeds-found' );
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# disallow because there is no whitelist at all or an empty whitelist
|
|
|
|
|
|
|
|
if ( !isset( $wgRSSUrlWhitelist )
|
|
|
|
|| !is_array( $wgRSSUrlWhitelist )
|
2022-04-06 00:05:34 +00:00
|
|
|
|| ( count( $wgRSSUrlWhitelist ) === 0 )
|
|
|
|
) {
|
|
|
|
return Utils::getErrorHtml( 'rss-empty-allow-list',
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
$input
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-04-19 01:03:58 +00:00
|
|
|
# disallow the feed url because the url is not allowed; or
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
# disallow because the wildcard joker is not present to allow any feed url
|
|
|
|
# which can be dangerous
|
|
|
|
|
|
|
|
if ( !( in_array( $input, $wgRSSUrlWhitelist ) )
|
|
|
|
&& !( in_array( "*", $wgRSSUrlWhitelist ) ) ) {
|
2022-09-28 19:55:49 +00:00
|
|
|
$listOfAllowed = $parser->getTargetLanguage()->listToText( $wgRSSUrlWhitelist );
|
|
|
|
$numberAllowed = $parser->getTargetLanguage()->formatNum( count( $wgRSSUrlWhitelist ) );
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
|
2022-04-06 00:05:34 +00:00
|
|
|
return Utils::getErrorHtml( 'rss-url-is-not-allowed',
|
2017-05-20 21:41:06 +00:00
|
|
|
[ $input, $listOfAllowed, $numberAllowed ]
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
);
|
|
|
|
|
2012-02-23 21:12:54 +00:00
|
|
|
}
|
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
2012-03-21 18:40:06 +00:00
|
|
|
|
2022-04-10 23:00:26 +00:00
|
|
|
if ( !MWHttpRequest::isValidURI( $input ) ) {
|
2022-04-06 00:05:34 +00:00
|
|
|
return Utils::getErrorHtml( 'rss-invalid-url', htmlspecialchars( $input ) );
|
2010-11-04 23:19:00 +00:00
|
|
|
}
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
|
2010-11-04 23:19:00 +00:00
|
|
|
if ( $wgRSSCacheCompare ) {
|
|
|
|
$timeout = $wgRSSCacheCompare;
|
|
|
|
} else {
|
|
|
|
$timeout = $wgRSSCacheAge;
|
|
|
|
}
|
2010-11-16 22:06:59 +00:00
|
|
|
|
2010-11-15 23:47:12 +00:00
|
|
|
$parser->getOutput()->updateCacheExpiry( $timeout );
|
2010-11-04 23:19:00 +00:00
|
|
|
|
|
|
|
$rss = new RSSParser( $input, $args );
|
|
|
|
|
|
|
|
$status = $rss->fetch();
|
|
|
|
|
|
|
|
# Check for errors.
|
2010-11-05 00:59:28 +00:00
|
|
|
if ( !$status->isGood() ) {
|
2018-05-07 18:09:56 +00:00
|
|
|
return wfMessage(
|
|
|
|
'rss-error', htmlspecialchars( $input ), Status::wrap( $status )->getWikitext()
|
2018-08-13 16:40:44 +00:00
|
|
|
)->escaped();
|
2010-11-05 00:59:28 +00:00
|
|
|
}
|
2010-11-04 23:19:00 +00:00
|
|
|
|
2010-11-05 00:59:28 +00:00
|
|
|
if ( !is_object( $rss->rss ) || !is_array( $rss->rss->items ) ) {
|
2022-04-06 00:05:34 +00:00
|
|
|
return Utils::getErrorHtml( 'rss-empty', htmlspecialchars( $input ) );
|
2010-11-05 00:59:28 +00:00
|
|
|
}
|
2010-11-04 23:19:00 +00:00
|
|
|
|
|
|
|
return $rss->renderFeed( $parser, $frame );
|
|
|
|
}
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
|
2010-11-04 23:19:00 +00:00
|
|
|
}
|