diff options
author | 2024-03-28 02:54:57 +0400 | |
---|---|---|
committer | 2024-03-28 03:03:58 +0400 | |
commit | 3996fa6aa64574c9698f1578d47d1178f93efc5e (patch) | |
tree | 71f96ff8ae57256b40dff969174b66a1bed48840 | |
parent | Fix case sensitivity bug in phishing button (diff) |
Update regex to discard trailing ')' and lowercase triggered URL before set difference
Updated the domain regex to account for trailing ")" characters.
Also, normalized triggered URLs to lowercase before executing the set difference performed to figure out unknown URLs in a message.
-rw-r--r-- | bot/exts/filtering/_filter_lists/domain.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/bot/exts/filtering/_filter_lists/domain.py b/bot/exts/filtering/_filter_lists/domain.py index 6b1a568bc..2bac19b00 100644 --- a/bot/exts/filtering/_filter_lists/domain.py +++ b/bot/exts/filtering/_filter_lists/domain.py @@ -13,7 +13,9 @@ from bot.exts.filtering._utils import clean_input if typing.TYPE_CHECKING: from bot.exts.filtering.filtering import Filtering -URL_RE = re.compile(r"https?://(\S+)", flags=re.IGNORECASE) +# Matches words that start with the http(s) protocol prefix +# Will not include, if present, the trailing closing parenthesis +URL_RE = re.compile(r"https?://(\S+)(?=\)|\b)", flags=re.IGNORECASE) class DomainsList(FilterList[DomainFilter]): @@ -56,7 +58,7 @@ class DomainsList(FilterList[DomainFilter]): triggers = await self[ListType.DENY].filter_list_result(new_ctx) ctx.notification_domain = new_ctx.notification_domain - unknown_urls = urls - {filter_.content for filter_ in triggers} + unknown_urls = urls - {filter_.content.lower() for filter_ in triggers} if unknown_urls: ctx.potential_phish[self] = unknown_urls |