From 9fd0a820c39e82e8259efd8c498adb3179f0dad6 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 26 Aug 2025 11:46:27 +0100 Subject: [PATCH] Check that actor attachments are dicts --- art.py | 9 +++++++++ briar.py | 9 +++++++++ cwtch.py | 9 +++++++++ discord.py | 9 +++++++++ donate.py | 9 +++++++++ enigma.py | 9 +++++++++ git.py | 6 ++++++ languages.py | 3 +++ matrix.py | 9 +++++++++ music.py | 9 +++++++++ peertube.py | 12 ++++++++++++ pgp.py | 33 +++++++++++++++++++++++++++++++++ pixelfed.py | 12 ++++++++++++ pronouns.py | 9 +++++++++ ssb.py | 9 +++++++++ tests.py | 2 ++ tox.py | 9 +++++++++ utils.py | 6 ++++++ webapp_utils.py | 6 ++++++ webfinger.py | 3 +++ website.py | 15 +++++++++++++++ xmpp.py | 9 +++++++++ youtube.py | 12 ++++++++++++ 23 files changed, 218 insertions(+) diff --git a/art.py b/art.py index 5dbcc7373..bacbbb45f 100644 --- a/art.py +++ b/art.py @@ -54,6 +54,9 @@ def get_art_site_url(actor_json: {}) -> str: if not isinstance(actor_json['attachment'], list): return '' for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue if not property_value.get('type'): continue if not isinstance(property_value['type'], str): @@ -86,6 +89,9 @@ def set_art_site_url(actor_json: {}, art_site_url: str) -> None: # remove any existing value property_found = None for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'].lower() @@ -104,6 +110,9 @@ def set_art_site_url(actor_json: {}, art_site_url: str) -> None: actor_json['attachment'].remove(property_found) for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] diff --git a/briar.py b/briar.py index 0aa5b6a85..39b1a5c8d 100644 --- a/briar.py +++ b/briar.py @@ -20,6 +20,9 @@ def get_briar_address(actor_json: {}) -> str: if not isinstance(actor_json['attachment'], list): return '' for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -85,6 +88,9 @@ def set_briar_address(actor_json: {}, briar_address: str) -> None: # remove any existing value property_found = None for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -104,6 +110,9 @@ def set_briar_address(actor_json: {}, briar_address: str) -> None: return for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] diff --git a/cwtch.py b/cwtch.py index 8cadc61b5..271494144 100644 --- a/cwtch.py +++ b/cwtch.py @@ -20,6 +20,9 @@ def get_cwtch_address(actor_json: {}) -> str: if not isinstance(actor_json['attachment'], list): return '' for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -71,6 +74,9 @@ def set_cwtch_address(actor_json: {}, cwtch_address: str) -> None: # remove any existing value property_found = None for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -90,6 +96,9 @@ def set_cwtch_address(actor_json: {}, cwtch_address: str) -> None: return for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] diff --git a/discord.py b/discord.py index efdf5eeae..19034ad8c 100644 --- a/discord.py +++ b/discord.py @@ -23,6 +23,9 @@ def get_discord(actor_json: {}) -> str: if not isinstance(actor_json['attachment'], list): return '' for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'].lower() @@ -54,6 +57,9 @@ def set_discord(actor_json: {}, discord: str) -> None: # remove any existing value property_found = None for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'].lower() @@ -72,6 +78,9 @@ def set_discord(actor_json: {}, discord: str) -> None: actor_json['attachment'].remove(property_found) for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] diff --git a/donate.py b/donate.py index fedbe2e94..2d625fb4d 100644 --- a/donate.py +++ b/donate.py @@ -33,6 +33,9 @@ def get_donation_url(actor_json: {}) -> str: return '' donation_type_list = _get_donation_types() for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -102,6 +105,9 @@ def set_donation_url(actor_json: {}, donate_url: str) -> None: # remove any existing value property_found = None for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -126,6 +132,9 @@ def set_donation_url(actor_json: {}, donate_url: str) -> None: donate_url + '' for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] diff --git a/enigma.py b/enigma.py index 3c7ea6613..6035efbe5 100644 --- a/enigma.py +++ b/enigma.py @@ -20,6 +20,9 @@ def get_enigma_pub_key(actor_json: {}) -> str: if not isinstance(actor_json['attachment'], list): return '' for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -54,6 +57,9 @@ def set_enigma_pub_key(actor_json: {}, enigma_pub_key: str) -> None: # remove any existing value property_found = None for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -73,6 +79,9 @@ def set_enigma_pub_key(actor_json: {}, enigma_pub_key: str) -> None: return for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] diff --git a/git.py b/git.py index c642ac00d..0980b0e83 100644 --- a/git.py +++ b/git.py @@ -237,6 +237,9 @@ def get_repo_url(actor_json: {}) -> str: repo_type = ('github', 'ghub', 'gitlab', 'glab', 'codeberg', 'launchpad', 'sourceforge', 'bitbucket', 'gitea') for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -268,6 +271,9 @@ def get_repo_url(actor_json: {}) -> str: repo_sites = ('github.com', 'gitlab.com', 'codeberg.org') for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue if not property_value.get('type'): continue prop_value_name, prop_value = \ diff --git a/languages.py b/languages.py index 0cf28de66..92cec1c12 100644 --- a/languages.py +++ b/languages.py @@ -77,6 +77,9 @@ def set_actor_languages(actor_json: {}, languages_str: str) -> None: # remove any existing value property_found = None for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] diff --git a/matrix.py b/matrix.py index b8d0416eb..d22bc1239 100644 --- a/matrix.py +++ b/matrix.py @@ -20,6 +20,9 @@ def get_matrix_address(actor_json: {}) -> str: if not isinstance(actor_json['attachment'], list): return '' for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -76,6 +79,9 @@ def set_matrix_address(actor_json: {}, matrix_address: str) -> None: # remove any existing value property_found = None for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -106,6 +112,9 @@ def set_matrix_address(actor_json: {}, matrix_address: str) -> None: return for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] diff --git a/music.py b/music.py index 129a044b4..5ada2841a 100644 --- a/music.py +++ b/music.py @@ -30,6 +30,9 @@ def get_music_site_url(actor_json: {}) -> str: if not isinstance(actor_json['attachment'], list): return '' for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue if not property_value.get('type'): continue if not isinstance(property_value['type'], str): @@ -62,6 +65,9 @@ def set_music_site_url(actor_json: {}, music_site_url: str) -> None: # remove any existing value property_found = None for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'].lower() @@ -80,6 +86,9 @@ def set_music_site_url(actor_json: {}, music_site_url: str) -> None: actor_json['attachment'].remove(property_found) for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] diff --git a/peertube.py b/peertube.py index 9c9f28e1f..389ac2f06 100644 --- a/peertube.py +++ b/peertube.py @@ -23,6 +23,9 @@ def get_peertube(actor_json: {}) -> str: if not isinstance(actor_json['attachment'], list): return '' for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'].lower() @@ -44,6 +47,9 @@ def get_peertube(actor_json: {}) -> str: return remove_html(peertube_text) for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue if not property_value.get('type'): continue prop_value_name, _ = \ @@ -68,6 +74,9 @@ def set_peertube(actor_json: {}, peertube: str) -> None: # remove any existing value property_found = None for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'].lower() @@ -86,6 +95,9 @@ def set_peertube(actor_json: {}, peertube: str) -> None: actor_json['attachment'].remove(property_found) for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] diff --git a/pgp.py b/pgp.py index af25b22d3..4667645f9 100644 --- a/pgp.py +++ b/pgp.py @@ -52,6 +52,9 @@ def get_email_address(actor_json: {}) -> str: if not isinstance(actor_json['attachment'], list): return '' for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -95,6 +98,9 @@ def get_deltachat_invite(actor_json: {}, translate: {}) -> str: match_strings = _get_deltachat_strings() match_strings.append(translate['DeltaChat'].lower()) for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -131,6 +137,9 @@ def get_pgp_pub_key(actor_json: {}) -> str: if not actor_json.get('attachment'): return '' for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -160,6 +169,9 @@ def get_pgp_fingerprint(actor_json: {}) -> str: if not actor_json.get('attachment'): return '' for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -202,6 +214,9 @@ def set_email_address(actor_json: {}, email_address: str) -> None: # remove any existing value property_found = None for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -221,6 +236,9 @@ def set_email_address(actor_json: {}, email_address: str) -> None: return for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -273,6 +291,9 @@ def set_deltachat_invite(actor_json: {}, invite_link: str, # remove any existing value property_found = None for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue if not property_value.get('name'): continue if not property_value.get('type'): @@ -312,6 +333,9 @@ def set_pgp_pub_key(actor_json: {}, pgp_pub_key: str) -> None: # remove any existing value property_found = None for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -331,6 +355,9 @@ def set_pgp_pub_key(actor_json: {}, pgp_pub_key: str) -> None: return for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -375,6 +402,9 @@ def set_pgp_fingerprint(actor_json: {}, fingerprint: str) -> None: # remove any existing value property_found = None for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -394,6 +424,9 @@ def set_pgp_fingerprint(actor_json: {}, fingerprint: str) -> None: return for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] diff --git a/pixelfed.py b/pixelfed.py index eb99a5c4b..389713847 100644 --- a/pixelfed.py +++ b/pixelfed.py @@ -27,6 +27,9 @@ def get_pixelfed(actor_json: {}) -> str: if not isinstance(actor_json['attachment'], list): return '' for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'].lower() @@ -65,6 +68,9 @@ def get_pixelfed(actor_json: {}) -> str: return pixelfed_text for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue if not property_value.get('type'): continue prop_value_name, _ = \ @@ -91,6 +97,9 @@ def set_pixelfed(actor_json: {}, pixelfed: str) -> None: # remove any existing value property_found = None for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'].lower() @@ -109,6 +118,9 @@ def set_pixelfed(actor_json: {}, pixelfed: str) -> None: actor_json['attachment'].remove(property_found) for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] diff --git a/pronouns.py b/pronouns.py index b2ed353d3..c5279dbec 100644 --- a/pronouns.py +++ b/pronouns.py @@ -23,6 +23,9 @@ def get_pronouns(actor_json: {}) -> str: if not isinstance(actor_json['attachment'], list): return '' for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'].lower() @@ -54,6 +57,9 @@ def set_pronouns(actor_json: {}, pronouns: str) -> None: # remove any existing value property_found = None for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'].lower() @@ -72,6 +78,9 @@ def set_pronouns(actor_json: {}, pronouns: str) -> None: actor_json['attachment'].remove(property_found) for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] diff --git a/ssb.py b/ssb.py index 0338da415..43de97a7c 100644 --- a/ssb.py +++ b/ssb.py @@ -20,6 +20,9 @@ def get_ssb_address(actor_json: {}) -> str: if not isinstance(actor_json['attachment'], list): return '' for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -76,6 +79,9 @@ def set_ssb_address(actor_json: {}, ssb_address: str) -> None: # remove any existing value property_found = None for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -95,6 +101,9 @@ def set_ssb_address(actor_json: {}, ssb_address: str) -> None: return for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] diff --git a/tests.py b/tests.py index 0e88caba8..151928a71 100644 --- a/tests.py +++ b/tests.py @@ -6828,6 +6828,8 @@ def test_update_actor(base_dir: str): assert len(actor_json['attachment']) > 0 property_found = False for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + continue if property_value['name'] == 'PGP': print('PGP property set within attachment') assert pub_key in property_value['value'] diff --git a/tox.py b/tox.py index 7977b2c61..b0e9063eb 100644 --- a/tox.py +++ b/tox.py @@ -20,6 +20,9 @@ def get_tox_address(actor_json: {}) -> str: if not isinstance(actor_json['attachment'], list): return '' for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -82,6 +85,9 @@ def set_tox_address(actor_json: {}, tox_address: str) -> None: # remove any existing value property_found = None for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -101,6 +107,9 @@ def set_tox_address(actor_json: {}, tox_address: str) -> None: return for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] diff --git a/utils.py b/utils.py index 4590e1761..29f28163b 100644 --- a/utils.py +++ b/utils.py @@ -171,6 +171,9 @@ def get_actor_languages_list(actor_json: {}) -> []: if not actor_json.get('attachment'): return [] for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -2703,6 +2706,9 @@ def get_actor_property_url(actor_json: {}, property_name: str) -> str: return '' property_name = property_name.lower() for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if not isinstance(property_value, dict): print("WARN: Actor attachment is not dict: " + str(property_value)) diff --git a/webapp_utils.py b/webapp_utils.py index a78252f27..f0d0eda94 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -291,6 +291,9 @@ def _set_actor_property_url(actor_json: {}, # remove any existing value property_found = None for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -323,6 +326,9 @@ def _set_actor_property_url(actor_json: {}, return for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] diff --git a/webfinger.py b/webfinger.py index 36465c126..3529036b2 100644 --- a/webfinger.py +++ b/webfinger.py @@ -533,6 +533,9 @@ def _webfinger_update_from_profile(wf_json: {}, actor_json: {}) -> bool: aliases_not_found.append(alias) for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] diff --git a/website.py b/website.py index af84a1f00..a3388e2d2 100644 --- a/website.py +++ b/website.py @@ -30,6 +30,9 @@ def get_website(actor_json: {}, translate: {}) -> str: match_strings = _get_website_strings() match_strings.append(website_str) for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -72,6 +75,9 @@ def get_gemini_link(actor_json: {}) -> str: return '' match_strings = _get_gemini_strings() for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -93,6 +99,9 @@ def get_gemini_link(actor_json: {}) -> str: return remove_link_tracking(url) for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue if not property_value.get('type'): continue prop_value_name, _ = \ @@ -131,6 +140,9 @@ def set_website(actor_json: {}, website_url: str, translate: {}) -> None: # remove any existing value property_found = None for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue if not property_value.get('name'): continue if not property_value.get('type'): @@ -174,6 +186,9 @@ def set_gemini_link(actor_json: {}, gemini_link: str) -> None: # remove any existing value property_found = None for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue if not property_value.get('name'): continue if not property_value.get('type'): diff --git a/xmpp.py b/xmpp.py index 5f2d20d13..1ece748de 100644 --- a/xmpp.py +++ b/xmpp.py @@ -20,6 +20,9 @@ def get_xmpp_address(actor_json: {}) -> str: if not isinstance(actor_json['attachment'], list): return '' for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'].lower() @@ -76,6 +79,9 @@ def set_xmpp_address(actor_json: {}, xmpp_address: str) -> None: # remove any existing value property_found = None for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] @@ -104,6 +110,9 @@ def set_xmpp_address(actor_json: {}, xmpp_address: str) -> None: return for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'] diff --git a/youtube.py b/youtube.py index 140f80a0b..a50f88aaf 100644 --- a/youtube.py +++ b/youtube.py @@ -23,6 +23,9 @@ def get_youtube(actor_json: {}) -> str: if not isinstance(actor_json['attachment'], list): return '' for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'].lower() @@ -44,6 +47,9 @@ def get_youtube(actor_json: {}) -> str: return remove_html(youtube_text) for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue if not property_value.get('type'): continue prop_value_name, _ = \ @@ -69,6 +75,9 @@ def set_youtube(actor_json: {}, youtube: str) -> None: # remove any existing value property_found = None for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name'].lower() @@ -87,6 +96,9 @@ def set_youtube(actor_json: {}, youtube: str) -> None: actor_json['attachment'].remove(property_found) for property_value in actor_json['attachment']: + if not isinstance(property_value, dict): + print("WARN: actor attachment is not dict: " + str(property_value)) + continue name_value = None if property_value.get('name'): name_value = property_value['name']