diff --git a/content.py b/content.py index d7f6fe1e4..36ef82ae3 100644 --- a/content.py +++ b/content.py @@ -45,6 +45,7 @@ from utils import acct_dir from utils import get_currencies from utils import remove_html from utils import remove_eol +from utils import is_yggdrasil_address from formats import get_image_extensions from petnames import get_pet_name from session import download_image @@ -1078,7 +1079,9 @@ def _add_mention(base_dir: str, word_str: str, http_prefix: str, possible_nickname + "" return True # @nick@domain - if not (possible_domain == 'localhost' or '.' in possible_domain): + if not (possible_domain == 'localhost' or + '.' in possible_domain or + is_yggdrasil_address(possible_domain)): return False recipient_actor = \ _mention_to_url(base_dir, http_prefix, diff --git a/cwlists.py b/cwlists.py index f9bf6e4c2..f9367f2ce 100644 --- a/cwlists.py +++ b/cwlists.py @@ -11,6 +11,7 @@ import os from utils import load_json from utils import get_content_from_post from utils import content_is_single_url +from utils import is_yggdrasil_address def load_cw_lists(base_dir: str, verbose: bool) -> {}: @@ -83,7 +84,7 @@ def _add_cw_match_domains(item: {}, content: str, cw_text: str, matched = False for domain in item['domains']: - if '.' in domain: + if '.' in domain or is_yggdrasil_address(domain): first_section = domain.split('.')[0] len_first_section = len(first_section) if len_first_section in range(1, 4): diff --git a/daemon_post_moderator.py b/daemon_post_moderator.py index fd3c67342..a4f6253b5 100644 --- a/daemon_post_moderator.py +++ b/daemon_post_moderator.py @@ -18,6 +18,7 @@ from utils import get_full_domain from utils import get_domain_from_actor from utils import get_nickname_from_actor from utils import get_instance_url +from utils import is_yggdrasil_address from flags import is_moderator from httpcodes import write2 from httpheaders import redirect_headers @@ -249,7 +250,9 @@ def moderator_actions(self, path: str, calling_domain: str, cookie: str, moderation_domain.split('@')[1] else: # assume the text is a domain name - if not full_block_domain and '.' in moderation_domain: + if (not full_block_domain and + ('.' in moderation_domain or + is_yggdrasil_address(moderation_domain))): nickname = '*' full_block_domain = \ moderation_domain.strip() @@ -284,7 +287,9 @@ def moderator_actions(self, path: str, calling_domain: str, cookie: str, full_block_domain = moderation_domain.split('@')[1] else: # assume the text is a domain name - if not full_block_domain and '.' in moderation_domain: + if (not full_block_domain and + ('.' in moderation_domain or + is_yggdrasil_address(moderation_domain))): nickname = '*' full_block_domain = moderation_domain.strip() if full_block_domain or nickname.startswith('#'): diff --git a/daemon_post_profile.py b/daemon_post_profile.py index aec678380..94b9c193e 100644 --- a/daemon_post_profile.py +++ b/daemon_post_profile.py @@ -23,6 +23,8 @@ 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 is_yggdrasil_url +from utils import is_yggdrasil_address from utils import data_dir from utils import set_premium_account from utils import save_json @@ -1687,10 +1689,12 @@ def _profile_post_alsoknownas(actor_json: {}, fields: {}, also_known_as_str += ', ' also_known_as_str += alt_actor also_known_as_ctr += 1 - if fields['alsoKnownAs'] != also_known_as_str and \ - '://' in fields['alsoKnownAs'] and \ - '@' not in fields['alsoKnownAs'] and \ - '.' in fields['alsoKnownAs']: + if fields['alsoKnownAs'] != ( + also_known_as_str and + '://' in fields['alsoKnownAs'] and + '@' not in fields['alsoKnownAs'] and + ('.' in fields['alsoKnownAs'] or + is_yggdrasil_url(fields['alsoKnownAs']))): if ';' in fields['alsoKnownAs']: fields['alsoKnownAs'] = \ fields['alsoKnownAs'].replace(';', ',') @@ -2481,7 +2485,8 @@ 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: + if '.' in new_twitter_domain or \ + is_yggdrasil_address(new_twitter_domain): set_config_param(base_dir, 'twitterdomain', new_twitter_domain) self.server.twitter_replacement_domain = new_twitter_domain @@ -2502,7 +2507,8 @@ 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: + if '.' in new_yt_domain or \ + is_yggdrasil_address(new_yt_domain): set_config_param(base_dir, 'youtubedomain', new_yt_domain) self.server.yt_replace_domain = new_yt_domain @@ -2758,7 +2764,8 @@ def _profile_post_avatar_image_ext(profile_media_types_uploaded: {}, actor_url = actor_url.replace(srch_str, rep_str) actor_json['icon']['url'] = actor_url print('actor_url: ' + actor_url) - if '.' in actor_url: + if '.' in actor_url or \ + is_yggdrasil_url(actor_url): img_ext = actor_url.split('.')[-1] if img_ext == 'jpg': img_ext = 'jpeg' @@ -2769,7 +2776,8 @@ def _profile_post_avatar_image_ext(profile_media_types_uploaded: {}, last_part_of_url = im_url.split('/')[-1] srch_str = '/' + last_part_of_url actor_json['image']['url'] = im_url.replace(srch_str, rep_str) - if '.' in im_url: + if '.' in im_url or \ + is_yggdrasil_url(im_url): img_ext = im_url.split('.')[-1] if img_ext == 'jpg': img_ext = 'jpeg' diff --git a/daemon_utils.py b/daemon_utils.py index e77f4dae2..66d497a2a 100644 --- a/daemon_utils.py +++ b/daemon_utils.py @@ -29,6 +29,7 @@ from posts import add_to_field from status import actor_status_expired from status import get_actor_status from mitm import detect_mitm +from utils import is_yggdrasil_url from utils import data_dir from utils import load_json from utils import save_json @@ -633,7 +634,8 @@ def show_person_options(self, calling_domain: str, path: str, options_profile_url = '' if len(options_list) > 2: options_profile_url = options_list[2] - if '.' in options_profile_url and \ + if ('.' in options_profile_url or + is_yggdrasil_url(options_profile_url)) and \ options_profile_url.startswith('/members/'): ext = options_profile_url.split('.')[-1] options_profile_url = options_profile_url.split('/members/')[1] diff --git a/epicyon.py b/epicyon.py index 0d63d5e47..d8b087eb3 100644 --- a/epicyon.py +++ b/epicyon.py @@ -76,6 +76,7 @@ from tests import run_all_tests from auth import store_basic_credentials from auth import create_password from utils import is_yggdrasil_url +from utils import is_yggdrasil_address from utils import get_event_categories from utils import replace_strings from utils import set_accounts_data_dir @@ -98,7 +99,6 @@ from utils import valid_nickname from utils import get_protocol_prefixes from utils import acct_dir from utils import resembles_url -from utils import is_yggdrasil_address from media import archive_media from media import get_attachment_media_type from delete import send_delete_via_server @@ -4365,7 +4365,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: + if '.' in yt_domain or is_yggdrasil_address(yt_domain): argb.yt_replace_domain = yt_domain twitter_domain = get_config_param(base_dir, 'twitterdomain') @@ -4374,7 +4374,7 @@ def _command_options() -> None: twitter_domain = twitter_domain.split('://')[1] if '/' in twitter_domain: twitter_domain = twitter_domain.split('/')[0] - if '.' in twitter_domain: + if '.' in twitter_domain or is_yggdrasil_address(twitter_domain): argb.twitter_replacement_domain = twitter_domain if set_theme(base_dir, theme_name, domain, diff --git a/follow.py b/follow.py index 9c29f6d92..005efca3d 100644 --- a/follow.py +++ b/follow.py @@ -11,6 +11,7 @@ import os from pprint import pprint from flags import has_group_type from utils import is_yggdrasil_address +from utils import is_yggdrasil_url from utils import get_user_paths from utils import acct_handle_dir from utils import has_object_string_object @@ -431,7 +432,7 @@ def _get_no_of_follows(base_dir: str, nickname: str, domain: str, if '#' in line: continue if '@' in line and \ - '.' in line and \ + ('.' in line or is_yggdrasil_url(line)) and \ not line.startswith('http'): ctr += 1 elif ((line.startswith('http') or diff --git a/posts.py b/posts.py index 52e84568b..4468ff340 100644 --- a/posts.py +++ b/posts.py @@ -2769,7 +2769,8 @@ 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 (('.' in external_domain or + is_yggdrasil_address(external_domain)) or external_domain == 'localhost'): continue mentioned_nickname = handle.split('@')[0]