From 4f280599e136c791894bb4dcce500e21a4d2ad7c Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Thu, 8 Sep 2016 21:42:31 +0200 Subject: [PATCH] RSS: use the original FeedParserDict for substitution instead of building a new keyword arguments dict by iteration. 'description' is a field in FeedParserDict, but is not present when iterating, which made it unavailable as a substitution variable. --- plugins/RSS/plugin.py | 6 +++--- plugins/RSS/test.py | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/plugins/RSS/plugin.py b/plugins/RSS/plugin.py index 49442852e..adb58df1c 100644 --- a/plugins/RSS/plugin.py +++ b/plugins/RSS/plugin.py @@ -406,10 +406,10 @@ class RSS(callbacks.Plugin): template = self.registryValue(key_name, channel) date = entry.get('published_parsed') date = utils.str.timestamp(date) - s = string.Template(template).safe_substitute( + s = string.Template(template).substitute( + entry, feed_name=feed.name, - date=date, - **entry) + date=date) return self._normalize_entry(s) def announce_entry(self, irc, channel, feed, entry): diff --git a/plugins/RSS/test.py b/plugins/RSS/test.py index 039405a3e..d64e8fde4 100644 --- a/plugins/RSS/test.py +++ b/plugins/RSS/test.py @@ -210,6 +210,16 @@ class RSSTestCase(ChannelPluginTestCase): self._feedMsg('rss remove xkcd2') feedparser._open_resource = old_open + def testDescription(self): + with conf.supybot.plugins.RSS.format.context('$description'): + old_open = feedparser._open_resource + feedparser._open_resource = constant(xkcd_new) + try: + self.assertRegexp('rss http://xkcd.com/rss.xml', + 'Although the oral exam for the doctorate was') + finally: + feedparser._open_resource = old_open + if network: def testRssinfo(self): self.assertNotError('rss info %s' % url) @@ -248,4 +258,5 @@ class RSSTestCase(ChannelPluginTestCase): self.assertNotError('rss info http://br-linux.org/main/index.xml') + # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: