mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-29 02:31:00 +00:00
Add 'domain' to the blocklist supported headers (#623)
This commit is contained in:
parent
c4a2b62016
commit
a69499c742
1 changed files with 3 additions and 3 deletions
|
@ -95,7 +95,7 @@ class FederationBlocklist(FormView):
|
||||||
blocklist = forms.FileField(
|
blocklist = forms.FileField(
|
||||||
help_text=(
|
help_text=(
|
||||||
"Blocklist file with one domain per line. "
|
"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"])],
|
validators=[FileExtensionValidator(allowed_extensions=["txt", "csv"])],
|
||||||
)
|
)
|
||||||
|
@ -107,13 +107,13 @@ class FederationBlocklist(FormView):
|
||||||
try:
|
try:
|
||||||
lines = form.cleaned_data["blocklist"].read().decode("utf-8").splitlines()
|
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)
|
reader = csv.DictReader(lines)
|
||||||
else:
|
else:
|
||||||
reader = csv.DictReader(lines, fieldnames=["#domain"])
|
reader = csv.DictReader(lines, fieldnames=["#domain"])
|
||||||
|
|
||||||
for row in reader:
|
for row in reader:
|
||||||
domain = row["#domain"].strip()
|
domain = row.get("#domain", row.get("domain", "")).strip()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
validator(domain)
|
validator(domain)
|
||||||
|
|
Loading…
Reference in a new issue