diff --git a/plugins/RSS/plugin.py b/plugins/RSS/plugin.py
index 9685241ee..aed17a2a0 100644
--- a/plugins/RSS/plugin.py
+++ b/plugins/RSS/plugin.py
@@ -526,6 +526,19 @@ class RSS(callbacks.Plugin):
if isinstance(item, dict) and 'value' in item:
value = item['value']
kwargs[key] = value
+
+ for key in ('summary', 'title'):
+ detail = kwargs.get('%s_detail' % key)
+ if isinstance(detail, dict) and detail.get('type') in \
+ ('text/html', 'application/xhtml+xml'):
+ kwargs[key] = utils.web.htmlToText(detail['value'])
+
+ if 'description' not in kwargs and kwargs[key]:
+ kwargs['description'] = kwargs[key]
+
+ if 'description' not in kwargs and kwargs.get('content'):
+ kwargs['description'] = kwargs['content']
+
s = string.Template(template).safe_substitute(entry, **kwargs, date=date)
return self._normalize_entry(s)
diff --git a/plugins/RSS/test.py b/plugins/RSS/test.py
index d5cdc9f6b..71c9d7dc5 100644
--- a/plugins/RSS/test.py
+++ b/plugins/RSS/test.py
@@ -359,83 +359,91 @@ class RSSTestCase(ChannelPluginTestCase):
'On the other hand, the refractor\'s')
@mock_urllib
- def testContentHtmlOnly(self, mock):
+ def testAtomContentHtmlOnly(self, mock):
timeFastForward(1.1)
- with conf.supybot.plugins.RSS.format.context('$content'):
- mock._data = """
+ mock._data = """
Recent Commits to anope:2.02023-10-04T16:14:39Z
- title with <pre>HTML<pre>
+ title with <pre>HTML</pre>2023-10-04T16:14:39Z
- content with <pre>HTML<pre>
+ content with <pre>HTML</pre>
"""
+ with conf.supybot.plugins.RSS.format.context('$content'):
+ self.assertRegexp('rss https://example.org',
+ 'content with HTML')
+ with conf.supybot.plugins.RSS.format.context('$description'):
self.assertRegexp('rss https://example.org',
'content with HTML')
@mock_urllib
- def testContentXhtmlOnly(self, mock):
+ def testAtomContentXhtmlOnly(self, mock):
timeFastForward(1.1)
- with conf.supybot.plugins.RSS.format.context('$content'):
- mock._data = """
+ mock._data = """
Recent Commits to anope:2.02023-10-04T16:14:39Z
- title with <pre>HTML<pre>
+ title with <pre>HTML</pre>2023-10-04T16:14:39Z
- content with
XHTML
+ content with
XHTML
"""
+ with conf.supybot.plugins.RSS.format.context('$content'):
+ self.assertRegexp('rss https://example.org',
+ 'content with XHTML')
+ with conf.supybot.plugins.RSS.format.context('$description'):
self.assertRegexp('rss https://example.org',
'content with XHTML')
@mock_urllib
- def testContentHtmlAndPlaintext(self, mock):
+ def testAtomContentHtmlAndPlaintext(self, mock):
timeFastForward(1.1)
- with conf.supybot.plugins.RSS.format.context('$content'):
- mock._data = """
+ mock._data = """
Recent Commits to anope:2.02023-10-04T16:14:39Z
- title with <pre>HTML<pre>
+ title with <pre>HTML</pre>2023-10-04T16:14:39Z
- content with <pre>HTML<pre>
+ content with <pre>HTML</pre>
content with plaintext
"""
+ with conf.supybot.plugins.RSS.format.context('$content'):
+ self.assertRegexp('rss https://example.org',
+ 'content with plaintext')
+ with conf.supybot.plugins.RSS.format.context('$description'):
self.assertRegexp('rss https://example.org',
'content with plaintext')
@mock_urllib
- def testContentPlaintextAndHtml(self, mock):
+ def testAtomContentPlaintextAndHtml(self, mock):
timeFastForward(1.1)
- with conf.supybot.plugins.RSS.format.context('$content'):
- mock._data = """
+ mock._data = """
Recent Commits to anope:2.02023-10-04T16:14:39Z
- title with <pre>HTML<pre>
+ title with <pre>HTML</pre>2023-10-04T16:14:39Z
@@ -443,12 +451,36 @@ class RSSTestCase(ChannelPluginTestCase):
content with plaintext
- content with <pre>HTML<pre>
+ content with <pre>HTML</pre>
"""
+ with conf.supybot.plugins.RSS.format.context('$content'):
self.assertRegexp('rss https://example.org',
'content with plaintext')
+ with conf.supybot.plugins.RSS.format.context('$description'):
+ self.assertRegexp('rss https://example.org',
+ 'content with plaintext')
+
+ @mock_urllib
+ def testRssDescriptionHtml(self, mock):
+ timeFastForward(1.1)
+ mock._data = """
+
+
+
+ feed title
+
+ en
+
+ title with <pre>HTML</pre>
+ description with <pre>HTML</pre>
+
+
+"""
+ with conf.supybot.plugins.RSS.format.context('$description'):
+ self.assertRegexp('rss https://example.org',
+ 'description with HTML')
@mock_urllib
def testFeedAttribute(self, mock):