plugins/RSS: If the feed supplies an encoding, encode the headlines with it.

This commit is contained in:
James Vega 2005-07-07 14:13:53 +00:00
parent a88f52bc7f
commit 14dc0c0201
2 changed files with 9 additions and 1 deletions

View File

@ -256,9 +256,13 @@ class RSS(callbacks.Plugin):
def getHeadlines(self, feed):
headlines = []
if 'encoding' in feed:
conv = lambda s: s.encode(feed['encoding'], 'replace')
else:
conv = lambda s: s
for d in feed['items']:
if 'title' in d:
title = utils.web.htmlToText(d['title']).strip()
title = conv(utils.web.htmlToText(d['title']).strip())
link = d.get('link')
if link:
headlines.append((title, link))

View File

@ -75,6 +75,10 @@ class RSSTestCase(ChannelPluginTestCase):
self.assertError('advogato')
self.assertError('rss advogato')
def testNonAsciiFeeds(self):
self.assertNotError('rss http://www.heise.de/newsticker/heise.rdf')
self.assertNotError('rss http://www.golem.de/rss.php?feed=ATOM0.3')
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: