From ed1179bf10958cdd384571b64d63579041952ed4 Mon Sep 17 00:00:00 2001 From: aikaterna <20862007+aikaterna@users.noreply.github.com> Date: Wed, 13 Oct 2021 09:41:50 -0700 Subject: [PATCH] [RSS] Patch out any ip addresses in bozo response --- rss/rss.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/rss/rss.py b/rss/rss.py index 0fccecf..a5485c2 100644 --- a/rss/rss.py +++ b/rss/rss.py @@ -25,7 +25,11 @@ from .tag_type import INTERNAL_TAGS, VALID_IMAGES, TagType log = logging.getLogger("red.aikaterna.rss") -__version__ = "1.5.0" +IPV4_RE = re.compile("\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}") +IPV6_RE = re.compile("([a-f0-9:]+:+)+[a-f0-9]+") + + +__version__ = "1.6.0" class RSS(commands.Cog): @@ -520,9 +524,12 @@ class RSS(commands.Cog): rss = feedparser.parse(text) if rss.bozo: + error_message = rss.feed.get("summary", str(rss))[:1500] + error_message = re.sub(IPV4_RE, "[REDACTED IP ADDRESS]", error_message) + error_message = re.sub(IPV6_RE, "[REDACTED IP ADDRESS]", error_message) msg = f"Bozo feed: feedparser is unable to parse the response from {url}.\n\n" msg += "Received content preview:\n" - msg += box(rss.feed.get("summary", str(rss))[:1500]) + msg += box(error_message) raise NoFeedContent(msg) return False else: