From e94eec081ac30b809b6348247d66a657d9bc9375 Mon Sep 17 00:00:00 2001 From: Jason McBrayer Date: Fri, 15 Feb 2019 17:14:05 -0500 Subject: [PATCH] Make sure not to match all toots if you don't have any filters --- brutaldon/views.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/brutaldon/views.py b/brutaldon/views.py index 334edb1..01a2935 100644 --- a/brutaldon/views.py +++ b/brutaldon/views.py @@ -164,6 +164,8 @@ def get_filters(mastodon, context=None): return [] def toot_matches_filters(toot, filters=[]): + if not filters: + return False def maybe_rewrite_filter(filter): if filter.whole_word: return f"\\b{filter.phrase}\\b" @@ -171,7 +173,10 @@ def toot_matches_filters(toot, filters=[]): return filter.phrase phrases = [maybe_rewrite_filter(x) for x in filters] pattern = "|".join(phrases) - return re.search(pattern, toot.spoiler_text + toot.content, re.I) + try: + return re.search(pattern, toot.spoiler_text + toot.content, re.I) + except: + return False ### ### View functions