diff --git a/content.py b/content.py
index 2394e21a1..40b380487 100644
--- a/content.py
+++ b/content.py
@@ -486,6 +486,22 @@ def add_web_links(content: str) -> str:
return content
+def safe_web_text(arbitrary_html: str) -> str:
+ """Turns arbitrary html into something safe.
+ So if the arbitrary html contains attack scripts those will be removed
+ """
+ # first remove the markup, so that we have something safe
+ safe_text = remove_html(arbitrary_html)
+ if not safe_text:
+ return ''
+ # remove any spurious characters found in podcast descriptions
+ remove_chars = ('Œ', 'â€', 'ğŸ', '�', ']]', '__')
+ for remchar in remove_chars:
+ safe_text = safe_text.replace(remchar, '')
+ # recreate any url links safely
+ return add_web_links(safe_text)
+
+
def _add_hash_tags(word_str: str, http_prefix: str, domain: str,
replace_hashtags: {}, post_hashtags: {}) -> bool:
"""Detects hashtags and adds them to the replacements dict
diff --git a/follow.py b/follow.py
index 70e7c0b71..d65636899 100644
--- a/follow.py
+++ b/follow.py
@@ -999,20 +999,20 @@ def send_follow_requestViaServer(base_dir: str, session,
# get the actor inbox for the To handle
origin_domain = from_domain
- (inboxUrl, _, _, fromPersonId, sharedInbox, avatarUrl,
- displayName, _) = get_person_box(signing_priv_key_pem, origin_domain,
- base_dir, session, wf_request,
- person_cache,
- project_version, http_prefix,
- from_nickname,
- from_domain, post_to_box, 52025)
+ (inbox_url, _, _, from_person_id, _, _,
+ _, _) = get_person_box(signing_priv_key_pem, origin_domain,
+ base_dir, session, wf_request,
+ person_cache,
+ project_version, http_prefix,
+ from_nickname,
+ from_domain, post_to_box, 52025)
- if not inboxUrl:
+ if not inbox_url:
if debug:
print('DEBUG: follow request no ' + post_to_box +
' was found for ' + handle)
return 3
- if not fromPersonId:
+ if not from_person_id:
if debug:
print('DEBUG: follow request no actor was found for ' + handle)
return 4
@@ -1026,10 +1026,10 @@ def send_follow_requestViaServer(base_dir: str, session,
}
post_result = \
post_json(http_prefix, from_domain_full,
- session, new_follow_json, [], inboxUrl, headers, 3, True)
+ session, new_follow_json, [], inbox_url, headers, 3, True)
if not post_result:
if debug:
- print('DEBUG: POST follow request failed for c2s to ' + inboxUrl)
+ print('DEBUG: POST follow request failed for c2s to ' + inbox_url)
return 5
if debug:
@@ -1095,22 +1095,22 @@ def send_unfollow_request_via_server(base_dir: str, session,
# get the actor inbox for the To handle
origin_domain = from_domain
- (inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
- displayName, _) = get_person_box(signing_priv_key_pem,
- origin_domain,
- base_dir, session,
- wf_request, person_cache,
- project_version, http_prefix,
- from_nickname,
- from_domain, post_to_box,
- 76536)
+ (inbox_url, _, _, from_person_id, _, _,
+ _, _) = get_person_box(signing_priv_key_pem,
+ origin_domain,
+ base_dir, session,
+ wf_request, person_cache,
+ project_version, http_prefix,
+ from_nickname,
+ from_domain, post_to_box,
+ 76536)
- if not inboxUrl:
+ if not inbox_url:
if debug:
print('DEBUG: unfollow no ' + post_to_box +
' was found for ' + handle)
return 3
- if not fromPersonId:
+ if not from_person_id:
if debug:
print('DEBUG: unfollow no actor was found for ' + handle)
return 4
@@ -1124,10 +1124,10 @@ def send_unfollow_request_via_server(base_dir: str, session,
}
post_result = \
post_json(http_prefix, from_domain_full,
- session, unfollow_json, [], inboxUrl, headers, 3, True)
+ session, unfollow_json, [], inbox_url, headers, 3, True)
if not post_result:
if debug:
- print('DEBUG: POST unfollow failed for c2s to ' + inboxUrl)
+ print('DEBUG: POST unfollow failed for c2s to ' + inbox_url)
return 5
if debug:
diff --git a/newswire.py b/newswire.py
index 8c35fb921..11867ba2d 100644
--- a/newswire.py
+++ b/newswire.py
@@ -229,8 +229,8 @@ def _add_newswire_dict_entry(base_dir: str, domain: str,
# Include tags from podcast categories
if podcast_properties:
if podcast_properties.get('explicit'):
- if '#NSFW' not in post_tags:
- post_tags.append('#NSFW')
+ if '#nsfw' not in post_tags:
+ post_tags.append('#nsfw')
post_tags += podcast_properties['categories']
@@ -446,7 +446,8 @@ def xml_podcast_to_dict(xml_item: str, xml_str: str) -> {}:
"""
if ' Some text including a link https://some.site/some-path