' + \
diff --git a/webapp_profile.py b/webapp_profile.py
index fe492e169..d5454f3b7 100644
--- a/webapp_profile.py
+++ b/webapp_profile.py
@@ -10,6 +10,7 @@ __module_group__ = "Web Interface"
import os
from pprint import pprint
from webfinger import webfinger_handle
+from utils import get_url_from_post
from utils import get_memorials
from utils import text_in_file
from utils import dangerous_markup
@@ -267,7 +268,8 @@ def html_profile_after_search(recent_posts_cache: {}, max_recent_posts: int,
avatar_url = ''
if profile_json.get('icon'):
if profile_json['icon'].get('url'):
- avatar_url = remove_html(profile_json['icon']['url'])
+ url_str = get_url_from_post(profile_json['icon']['url'])
+ avatar_url = remove_html(url_str)
if not avatar_url:
avatar_url = get_person_avatar_url(base_dir, person_url, person_cache)
display_name = search_nickname
@@ -324,8 +326,8 @@ def html_profile_after_search(recent_posts_cache: {}, max_recent_posts: int,
# profileBackgroundImage = ''
# if profile_json.get('image'):
# if profile_json['image'].get('url'):
- # profileBackgroundImage = \
- # remove_html(profile_json['image']['url'])
+ # url_str = get_url_from_post(profile_json['image']['url'])
+ # profileBackgroundImage = remove_html(url_str)
# url to return to
back_url = path
@@ -348,7 +350,8 @@ def html_profile_after_search(recent_posts_cache: {}, max_recent_posts: int,
image_url = ''
if profile_json.get('image'):
if profile_json['image'].get('url'):
- image_url = remove_html(profile_json['image']['url'])
+ url_str = get_url_from_post(profile_json['image']['url'])
+ image_url = remove_html(url_str)
also_known_as = None
if profile_json.get('alsoKnownAs'):
@@ -1194,7 +1197,8 @@ def html_profile(signing_priv_key_pem: str,
if profile_json.get('hasOccupation'):
occupation_name = get_occupation_name(profile_json)
- avatar_url = remove_html(profile_json['icon']['url'])
+ url_str = get_url_from_post(profile_json['icon']['url'])
+ avatar_url = remove_html(url_str)
# use alternate path for local avatars to avoid any caching issues
if '://' + domain_full + '/system/accounts/avatars/' in avatar_url:
avatar_url = \
diff --git a/webapp_search.py b/webapp_search.py
index f7a84daab..9f24c7172 100644
--- a/webapp_search.py
+++ b/webapp_search.py
@@ -10,6 +10,7 @@ __module_group__ = "Web Interface"
import os
from shutil import copyfile
import urllib.parse
+from utils import get_url_from_post
from utils import date_from_string_format
from utils import get_attributed_to
from utils import get_actor_from_post_id
@@ -571,7 +572,8 @@ def html_skills_search(actor: str, translate: {}, base_dir: str,
skill_level_str = '0' + skill_level_str
if skill_level < 10:
skill_level_str = '0' + skill_level_str
- icon_url = remove_html(actor_json['icon']['url'])
+ url_str = get_url_from_post(actor_json['icon']['url'])
+ icon_url = remove_html(url_str)
index_str = \
skill_level_str + ';' + actor + ';' + \
actor_json['name'] + \
@@ -611,7 +613,9 @@ def html_skills_search(actor: str, translate: {}, base_dir: str,
skill_level_str = '0' + skill_level_str
if skill_level < 10:
skill_level_str = '0' + skill_level_str
- icon_url = remove_html(actor_json['icon']['url'])
+ url_str = \
+ get_url_from_post(actor_json['icon']['url'])
+ icon_url = remove_html(url_str)
index_str = \
skill_level_str + ';' + actor + ';' + \
actor_json['name'] + \
@@ -1375,7 +1379,8 @@ def rss_hashtag_search(nickname: str, domain: str, port: int,
for attach in post_json_object['object']['attachment']:
if not attach.get('url'):
continue
- attach_url = remove_html(attach['url'])
+ url_str = get_url_from_post(attach['url'])
+ attach_url = remove_html(url_str)
hashtag_feed += \
' ' + attach_url + ''
hashtag_feed += ' '
diff --git a/webapp_utils.py b/webapp_utils.py
index 7871608b3..9a6497799 100644
--- a/webapp_utils.py
+++ b/webapp_utils.py
@@ -12,6 +12,7 @@ from shutil import copyfile
from collections import OrderedDict
from session import get_json
from session import get_json_valid
+from utils import get_url_from_post
from utils import get_media_url_from_video
from utils import get_attributed_to
from utils import local_network_host
@@ -857,7 +858,8 @@ def html_header_with_person_markup(css_filename: str, instance_title: str,
domain_full = actor_json['id'].split('://')[1].split('/')[0]
handle = actor_json['preferredUsername'] + '@' + domain_full
- icon_url = remove_html(actor_json['icon']['url'])
+ url_str = get_url_from_post(actor_json['icon']['url'])
+ icon_url = remove_html(url_str)
person_markup = \
' "about": {\n' + \
' "@type" : "Person",\n' + \
@@ -893,7 +895,8 @@ def html_header_with_person_markup(css_filename: str, instance_title: str,
' \n'
description = remove_html(description)
- actor2_url = remove_html(actor_json['url'])
+ url_str = get_url_from_post(actor_json['url'])
+ actor2_url = remove_html(url_str)
og_metadata = \
" \n" + \
" \n'
if post_json_object['object'].get('url'):
- image_post_url = post_json_object['object']['url']
+ url_str = post_json_object['object']['url']
+ image_post_url = get_url_from_post(url_str)
else:
image_post_url = post_json_object['object']['id']
image_post_url = remove_html(image_post_url)
@@ -1554,7 +1559,8 @@ def get_post_attachments_as_html(base_dir: str,
if box_name == 'tlmedia':
gallery_str += '\n'
if post_json_object['object'].get('url'):
- video_post_url = post_json_object['object']['url']
+ url_str = post_json_object['object']['url']
+ video_post_url = get_url_from_post(url_str)
else:
video_post_url = post_json_object['object']['id']
video_post_url = remove_html(video_post_url)
@@ -1629,7 +1635,8 @@ def get_post_attachments_as_html(base_dir: str,
attachment_ctr += 1
elif _is_audio_mime_type(media_type):
extension = '.mp3'
- audio_url = remove_html(attach['url'])
+ url_str = get_url_from_post(attach['url'])
+ audio_url = remove_html(url_str)
if audio_url in attached_urls:
continue
attached_urls.append(audio_url)
@@ -1664,7 +1671,8 @@ def get_post_attachments_as_html(base_dir: str,
gallery_str += ' \n'
gallery_str += ' \n'
if post_json_object['object'].get('url'):
- audio_post_url = post_json_object['object']['url']
+ url_str = post_json_object['object']['url']
+ audio_post_url = get_url_from_post(url_str)
else:
audio_post_url = post_json_object['object']['id']
audio_post_url = remove_html(audio_post_url)
diff --git a/webfinger.py b/webfinger.py
index 87b0b9fec..005521f91 100644
--- a/webfinger.py
+++ b/webfinger.py
@@ -13,6 +13,7 @@ from session import get_json
from session import get_json_valid
from cache import store_webfinger_in_cache
from cache import get_webfinger_from_cache
+from utils import get_url_from_post
from utils import remove_html
from utils import acct_handle_dir
from utils import get_attachment_property_value
@@ -433,7 +434,8 @@ def _webfinger_update_avatar(wf_json: {}, actor_json: {}) -> bool:
"""Updates the avatar image link
"""
found = False
- avatar_url = remove_html(actor_json['icon']['url'])
+ url_str = get_url_from_post(actor_json['icon']['url'])
+ avatar_url = remove_html(url_str)
media_type = actor_json['icon']['mediaType']
for link in wf_json['links']:
if not link.get('rel'):
@@ -463,7 +465,8 @@ def _webfinger_update_vcard(wf_json: {}, actor_json: {}) -> bool:
if link.get('type'):
if link['type'] == 'text/vcard':
return False
- actor_url = remove_html(actor_json['url'])
+ url_str = get_url_from_post(actor_json['url'])
+ actor_url = remove_html(url_str)
wf_json['links'].append({
"href": actor_url,
"rel": "http://webfinger.net/rel/profile-page",