mirror of https://gitlab.com/bashrc2/epicyon
Disallow federated blocking of your own domain
parent
8a6f30f507
commit
0e35ee7f18
13
blocking.py
13
blocking.py
|
@ -1871,7 +1871,7 @@ def load_federated_blocks_endpoints(base_dir: str) -> []:
|
||||||
return block_federated_endpoints
|
return block_federated_endpoints
|
||||||
|
|
||||||
|
|
||||||
def _valid_blocklist_entry(text: str) -> bool:
|
def _valid_federated_blocklist_entry(text: str, domain: str) -> bool:
|
||||||
"""is the given blocklist entry valid?
|
"""is the given blocklist entry valid?
|
||||||
"""
|
"""
|
||||||
if ' ' in text or \
|
if ' ' in text or \
|
||||||
|
@ -1880,6 +1880,11 @@ def _valid_blocklist_entry(text: str) -> bool:
|
||||||
'.' not in text or \
|
'.' not in text or \
|
||||||
'<' in text:
|
'<' in text:
|
||||||
return False
|
return False
|
||||||
|
if text == domain:
|
||||||
|
return False
|
||||||
|
if text.endswith('@' + domain) or \
|
||||||
|
text.endswith('://' + domain):
|
||||||
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -1935,7 +1940,8 @@ def _update_federated_blocks(session, base_dir: str,
|
||||||
handle = block_dict
|
handle = block_dict
|
||||||
if handle.startswith('@'):
|
if handle.startswith('@'):
|
||||||
handle = handle[1:]
|
handle = handle[1:]
|
||||||
if _valid_blocklist_entry(handle):
|
if _valid_federated_blocklist_entry(handle,
|
||||||
|
domain):
|
||||||
if handle not in new_block_api_str:
|
if handle not in new_block_api_str:
|
||||||
new_block_api_str += handle + '\n'
|
new_block_api_str += handle + '\n'
|
||||||
if handle not in block_federated:
|
if handle not in block_federated:
|
||||||
|
@ -1952,7 +1958,8 @@ def _update_federated_blocks(session, base_dir: str,
|
||||||
handle = block_dict[block_fieldname]
|
handle = block_dict[block_fieldname]
|
||||||
if handle.startswith('@'):
|
if handle.startswith('@'):
|
||||||
handle = handle[1:]
|
handle = handle[1:]
|
||||||
if not _valid_blocklist_entry(handle):
|
if not _valid_federated_blocklist_entry(handle,
|
||||||
|
domain):
|
||||||
continue
|
continue
|
||||||
if handle not in new_block_api_str:
|
if handle not in new_block_api_str:
|
||||||
new_block_api_str += handle + '\n'
|
new_block_api_str += handle + '\n'
|
||||||
|
|
Loading…
Reference in New Issue