aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Boris Muratov <[email protected]>2023-06-21 22:41:53 +0300
committerGravatar GitHub <[email protected]>2023-06-21 20:41:53 +0100
commitba4dcfda52734eaa5c9e6b7c91af0201260ebb3b (patch)
tree87bb6e7db7fda6b5ea23bf882853a4c5c7351b16
parentMerge pull request #2652 from python-discord/vivek/incidents-context (diff)
Remove casing in domain filtering (#2654)
The extraction of domains from a message in the filterlist removes casing, but the checks of individual filters kept theirs, which led to some filters not working. This assumes that two URLs that differ only by casing are identical, which isn't necessarily true, but a conflict is very unlikely.
-rw-r--r--bot/exts/filtering/_filters/domain.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/bot/exts/filtering/_filters/domain.py b/bot/exts/filtering/_filters/domain.py
index ac9cc9018..c3f7f2886 100644
--- a/bot/exts/filtering/_filters/domain.py
+++ b/bot/exts/filtering/_filters/domain.py
@@ -36,11 +36,11 @@ class DomainFilter(Filter):
async def triggered_on(self, ctx: FilterContext) -> bool:
"""Searches for a domain within a given context."""
- domain = tldextract.extract(self.content).registered_domain
+ domain = tldextract.extract(self.content).registered_domain.lower()
for found_url in ctx.content:
extract = tldextract.extract(found_url)
- if self.content in found_url and extract.registered_domain == domain:
+ if self.content.lower() in found_url and extract.registered_domain == domain:
if self.extra_fields.only_subdomains:
if not extract.subdomain and not urlparse(f"https://{found_url}").path:
return False