From cc473795bf9f2f601dc88dc4dd8a2710e4fca3f0 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Mon, 31 Oct 2022 16:33:11 +0200 Subject: [PATCH] make banned domains case insensitive --- files/helpers/sanitize.py | 2 +- files/routes/admin.py | 2 +- files/routes/posts.py | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 3a1d08a02..44847f08f 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -364,7 +364,7 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_marseys if not href: continue url = urlparse(href) d = tldextract.extract(href).registered_domain + url.path - domain_list.add(d) + domain_list.add(d.lower()) banned_domains = g.db.query(BannedDomain).all() for x in banned_domains: diff --git a/files/routes/admin.py b/files/routes/admin.py index 3ab37fa8e..6ecd2bfb3 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -1386,7 +1386,7 @@ def admin_banned_domains(v): @admin_level_required(PERMS['DOMAINS_BAN']) def ban_domain(v): - domain=request.values.get("domain", "").strip() + domain=request.values.get("domain", "").strip().lower() if not domain: abort(400) reason=request.values.get("reason").strip() diff --git a/files/routes/posts.py b/files/routes/posts.py index 98548077d..3a0b3fddc 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -687,6 +687,7 @@ def submit_post(v, sub=None): return redirect(repost.permalink) y = tldextract.extract(url).registered_domain + parsed_url.path + y = y.lower() banned_domains = g.db.query(BannedDomain).all() for x in banned_domains: if y.startswith(x.domain):