mirror of https://gitlab.com/bashrc2/epicyon
Checking domains
parent
217b7d96fa
commit
753a1156fe
|
|
@ -20,6 +20,7 @@ from flags import is_pgp_encrypted
|
|||
from flags import contains_pgp_public_key
|
||||
from flags import is_float
|
||||
from flags import is_right_to_left_text
|
||||
from utils import resembles_domain
|
||||
from utils import string_starts_with
|
||||
from utils import replace_strings
|
||||
from utils import data_dir
|
||||
|
|
@ -1078,7 +1079,7 @@ def _add_mention(base_dir: str, word_str: str, http_prefix: str,
|
|||
return True
|
||||
# @nick@domain
|
||||
if not (possible_domain == 'localhost' or
|
||||
'.' in possible_domain or
|
||||
resembles_domain(possible_domain) or
|
||||
is_yggdrasil_address(possible_domain)):
|
||||
return False
|
||||
recipient_actor = \
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import os
|
|||
import errno
|
||||
import urllib.parse
|
||||
from socket import error as SocketError
|
||||
from utils import resembles_domain
|
||||
from utils import string_starts_with
|
||||
from utils import data_dir
|
||||
from utils import delete_post
|
||||
|
|
@ -247,7 +248,7 @@ def moderator_actions(self, path: str, calling_domain: str, cookie: str,
|
|||
else:
|
||||
# assume the text is a domain name
|
||||
if (not full_block_domain and
|
||||
('.' in moderation_domain or
|
||||
(resembles_domain(moderation_domain) or
|
||||
is_yggdrasil_address(moderation_domain))):
|
||||
nickname = '*'
|
||||
full_block_domain = \
|
||||
|
|
@ -282,7 +283,7 @@ def moderator_actions(self, path: str, calling_domain: str, cookie: str,
|
|||
else:
|
||||
# assume the text is a domain name
|
||||
if (not full_block_domain and
|
||||
('.' in moderation_domain or
|
||||
(resembles_domain(moderation_domain) or
|
||||
is_yggdrasil_address(moderation_domain))):
|
||||
nickname = '*'
|
||||
full_block_domain = moderation_domain.strip()
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ from flags import is_premium_account
|
|||
from flags import is_moderator
|
||||
from timeFunctions import get_account_timezone
|
||||
from timeFunctions import set_account_timezone
|
||||
from utils import resembles_domain
|
||||
from utils import is_yggdrasil_url
|
||||
from utils import is_yggdrasil_address
|
||||
from utils import data_dir
|
||||
|
|
@ -2509,7 +2510,7 @@ def _profile_post_twitter_alt_domain(base_dir: str, fields: {},
|
|||
new_twitter_domain = new_twitter_domain.split('://')[1]
|
||||
if '/' in new_twitter_domain:
|
||||
new_twitter_domain = new_twitter_domain.split('/')[0]
|
||||
if '.' in new_twitter_domain or \
|
||||
if resembles_domain(new_twitter_domain) or \
|
||||
is_yggdrasil_address(new_twitter_domain):
|
||||
set_config_param(base_dir, 'twitterdomain',
|
||||
new_twitter_domain)
|
||||
|
|
@ -2531,7 +2532,7 @@ def _profile_post_youtube_alt_domain(base_dir: str, fields: {},
|
|||
new_yt_domain = new_yt_domain.split('://')[1]
|
||||
if '/' in new_yt_domain:
|
||||
new_yt_domain = new_yt_domain.split('/')[0]
|
||||
if '.' in new_yt_domain or \
|
||||
if resembles_domain(new_yt_domain) or \
|
||||
is_yggdrasil_address(new_yt_domain):
|
||||
set_config_param(base_dir, 'youtubedomain',
|
||||
new_yt_domain)
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ from tests import test_update_actor
|
|||
from tests import run_all_tests
|
||||
from auth import store_basic_credentials
|
||||
from auth import create_password
|
||||
from utils import resembles_domain
|
||||
from utils import string_starts_with
|
||||
from utils import is_yggdrasil_url
|
||||
from utils import is_yggdrasil_address
|
||||
|
|
@ -4366,7 +4367,7 @@ def _command_options() -> None:
|
|||
yt_domain = yt_domain.split('://')[1]
|
||||
if '/' in yt_domain:
|
||||
yt_domain = yt_domain.split('/')[0]
|
||||
if '.' in yt_domain or is_yggdrasil_address(yt_domain):
|
||||
if resembles_domain(yt_domain) or is_yggdrasil_address(yt_domain):
|
||||
argb.yt_replace_domain = yt_domain
|
||||
|
||||
twitter_domain = get_config_param(base_dir, 'twitterdomain')
|
||||
|
|
@ -4375,7 +4376,8 @@ def _command_options() -> None:
|
|||
twitter_domain = twitter_domain.split('://')[1]
|
||||
if '/' in twitter_domain:
|
||||
twitter_domain = twitter_domain.split('/')[0]
|
||||
if '.' in twitter_domain or is_yggdrasil_address(twitter_domain):
|
||||
if resembles_domain(twitter_domain) or \
|
||||
is_yggdrasil_address(twitter_domain):
|
||||
argb.twitter_replacement_domain = twitter_domain
|
||||
|
||||
if set_theme(base_dir, theme_name, domain,
|
||||
|
|
|
|||
3
posts.py
3
posts.py
|
|
@ -45,6 +45,7 @@ from timeFunctions import date_utcnow
|
|||
from timeFunctions import date_from_string_format
|
||||
from timeFunctions import date_epoch
|
||||
from timeFunctions import valid_post_date
|
||||
from utils import resembles_domain
|
||||
from utils import string_starts_with
|
||||
from utils import is_yggdrasil_address
|
||||
from utils import resembles_url
|
||||
|
|
@ -2770,7 +2771,7 @@ def get_mentioned_people(base_dir: str, http_prefix: str,
|
|||
continue
|
||||
else:
|
||||
external_domain = handle.split('@')[1]
|
||||
if not (('.' in external_domain or
|
||||
if not ((resembles_domain(external_domain) or
|
||||
is_yggdrasil_address(external_domain)) or
|
||||
external_domain == 'localhost'):
|
||||
continue
|
||||
|
|
|
|||
4
utils.py
4
utils.py
|
|
@ -4035,8 +4035,8 @@ def resembles_domain(text: str) -> bool:
|
|||
Why not use validators? It's so that exotic, potentially p2p domains
|
||||
may be used.
|
||||
"""
|
||||
if ' ' in text or '-' in text or '<' in text or ';' in text or \
|
||||
'"' in text or '(' in text or ')' in text:
|
||||
if ' ' in text or '/' in text or '-' in text or '<' in text or \
|
||||
';' in text or '"' in text or '(' in text or ')' in text:
|
||||
return False
|
||||
|
||||
# conventional domain
|
||||
|
|
|
|||
Loading…
Reference in New Issue