Wordpress RSS parser bugs discovered and fixed
July 14, 2008 at 5:02 pm, niflostancuHey, niflostancu here, for the first time!
This post is about some bugs I found in Wordpress, actually Scorpiono found them, I only analyzed and fixed them.
Both are on the same feature, the wp_rss function (and it’s dependencies), which allows you to automatically grab and display RSS feeds in your sidebar (somewhat like the upcoming Brutus RSS plugin, but you can’t make posts from them).
The first one is a bug in the MagpieRSS ATOM feed parser, where, on some ATOM feeds, the link is empty (wp-includes/rss.php, lines 186-197).
The other bug affects all types of feeds with non-ISO-8859-1 encoding (including UTF-8, the most used), where some special characters like the pound and euro sign, diacritics etc aren’t shown correctly (htmlentities was used without the UTF-8 encoding parameter, wp-includes/rss.php, lines 850 and 869)
I attached here a fixed
rss.php.zip (WP 2.5.1+ ONLY), uncompress it and upload it in wp-includes, replacing the old one. For other versions and if the bugs are not solved, for future versions, here is what I changed:
- For the first bug, I changed the wp_rss function like this:
foreach ( $rss->items as $item ) {
if (!$item['link']) $item['link']=$item['link_']; //added this linealthough I could fix this on class level, MagpieRSS class, feed_start_element function, but I wanted a quick fix that would take effect immediately (wordpress usually caches parsed feeds):
elseif ($this->feed_type == ATOM and $el == ‘link’ )
{
if ( isset($attrs['rel']) and $attrs['rel'] == ‘alternate’ )
{
$link_el = ‘link’;
}
elseif ( empty($attrs['rel']) ) {$link_el = ‘link’;} // added this line
else {
$link_el = ‘link_’ . $attrs['rel'];
}
$this->append($link_el, $attrs['href']);
} - For the second you have to search for htmlentities (found only in wp_rss and get_rss functions) and replace the words with attribute_escape:
attribute_escape( $item['title'] )






Category 


WLD says:
On July 15, 2008at 11:15 am
thanks guys, I’ll fix it soon!
Keep up the good work
Scorpiono says:
On July 15, 2008at 12:52 pm
Cheers!
Wordpress 2.6 - upgraded but still wp_rss bug - Scorpiono.com says:
On July 15, 2008at 3:28 pm
[...] Wordpress RSS parser bugs discovered and fixed [...]
G-G says:
On September 23, 2009at 2:01 pm
thank so much, it really helpfull
Sean Perry says:
On May 20, 2010at 7:39 pm
RSS Feeds are really very helpful and you could get site and news updates from it.`’`
Zoe Ali says:
On July 28, 2010at 10:26 am
RSS feeds are really great because you are always updated with the latest news or blog posts.~*~