From a69499c742762070333d32f9f8fe5fb15a5622a0 Mon Sep 17 00:00:00 2001 From: Humberto Rocha Date: Thu, 3 Aug 2023 12:41:47 -0400 Subject: [PATCH] Add 'domain' to the blocklist supported headers (#623) --- users/views/admin/federation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/users/views/admin/federation.py b/users/views/admin/federation.py index 22105cb..0fcbb61 100644 --- a/users/views/admin/federation.py +++ b/users/views/admin/federation.py @@ -95,7 +95,7 @@ class FederationBlocklist(FormView): blocklist = forms.FileField( help_text=( "Blocklist file with one domain per line. " - "Oliphant blocklist format is also supported." + "CSVs with 'domain' and '#domain' headers are also supported." ), validators=[FileExtensionValidator(allowed_extensions=["txt", "csv"])], ) @@ -107,13 +107,13 @@ class FederationBlocklist(FormView): try: lines = form.cleaned_data["blocklist"].read().decode("utf-8").splitlines() - if "#domain" in lines[0]: + if "#domain" in lines[0] or "domain" in lines[0]: reader = csv.DictReader(lines) else: reader = csv.DictReader(lines, fieldnames=["#domain"]) for row in reader: - domain = row["#domain"].strip() + domain = row.get("#domain", row.get("domain", "")).strip() try: validator(domain)