diff options
author | 2021-09-09 18:47:16 +0100 | |
---|---|---|
committer | 2021-09-09 18:47:16 +0100 | |
commit | 14e910ee0997c6edca02d73b7cfd25b98dabfa57 (patch) | |
tree | a83361ec5e3a9d773ae0c56c9676466db14ea806 | |
parent | Merge pull request #1819 from python-discord/string-formatting-tag (diff) | |
parent | Merge branch 'main' into Only-check-domain-filters-against-URL-like-parts-of-... (diff) |
Merge pull request #1788 from python-discord/Only-check-domain-filters-against-URL-like-parts-of-a-message
Only check URL-like objects against domain filters
-rw-r--r-- | bot/exts/filters/filtering.py | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/bot/exts/filters/filtering.py b/bot/exts/filters/filtering.py index 10cc7885d..7e698880f 100644 --- a/bot/exts/filters/filtering.py +++ b/bot/exts/filters/filtering.py @@ -478,16 +478,12 @@ class Filtering(Cog): Second return value is a reason of URL blacklisting (can be None). """ text = self.clean_input(text) - if not URL_RE.search(text): - return False, None - text = text.lower() domain_blacklist = self._get_filterlist_items("domain_name", allowed=False) - - for url in domain_blacklist: - if url.lower() in text: - return True, self._get_filterlist_value("domain_name", url, allowed=False)["comment"] - + for match in URL_RE.finditer(text): + for url in domain_blacklist: + if url.lower() in match.group(1).lower(): + return True, self._get_filterlist_value("domain_name", url, allowed=False)["comment"] return False, None @staticmethod |