From 7c4a28d7fd3287c30d2846e99c9b9e4b8f3c35c6 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Mon, 1 Jun 2015 19:32:40 +0200 Subject: [PATCH] RSS: Remove illegal characters from entries. --- plugins/RSS/plugin.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/RSS/plugin.py b/plugins/RSS/plugin.py index 7f69f1406..9b47c2873 100644 --- a/plugins/RSS/plugin.py +++ b/plugins/RSS/plugin.py @@ -361,6 +361,8 @@ class RSS(callbacks.Plugin): return False return True + _normalize_entry = utils.str.multipleReplacer( + {'\r': ' ', '\n': ' ', '\x00': ''}) def format_entry(self, channel, feed, entry, is_announce): key_name = 'announceFormat' if is_announce else 'format' if feed.name in self.registryValue('feeds'): @@ -371,10 +373,11 @@ class RSS(callbacks.Plugin): template = self.registryValue(key_name, channel) date = entry.get('published_parsed') date = utils.str.timestamp(date) - return string.Template(template).safe_substitute( + s = string.Template(template).safe_substitute( feed_name=feed.name, date=date, **entry) + return self._normalize_entry(s) def announce_entry(self, irc, channel, feed, entry): if self.should_send_entry(channel, entry):