Zum Inhalt springen

sNews - Improving the RSS Feed

Fixing quotes in RSS titles

Another small fix for snews RSS feed. Quotes in titles may break the validity of the rss feed, if you are using a UTF-8 as your charset and have a quote in an article title.

Especially if you are using UTF-8 as your charset, you may come accross a problem when trying to use quotes in titles. They get converted to html entities (") in the database, which is fine. However, the html entity will turn up in the snews rss feed unconverted and may break validation (snews 1.7, March 2010). The fix for this is quite simple … here we go:

in the rss_contents function (near to end) find:
and replace it with:

Better w3c validation

While checking the validation for snews rss feeds, I came up against some problems and found some fixes, which may help others who have similar proplems. The first problems I encountered was the the w3c rss validator told me that in the link tag the rel=self was missing. This is easily fixed by adding the following lines to the rss_contents() in snews.php.

echo '
<?xml version="1.0" encoding="'.s('charset').'"?>
<rss version="2.0">
and replace with:
if (substr($rss_item,-1) != '/') {
  $rss_item_link = $rss_item . '/';
} else {
  $rss_item_link = $rss_item;
echo '
<atom:link href="'._SITE.$rss_item_link.'" rel="self" type="application/rss+xml" />

Kommentiere diesen Artikel

Kommentar (erforderlich) (keine Anzeige) (optional)
Ja, erkenne mich, wenn ich das nächste mal hier bin