From 5cd720c77f25f561285723c2af436f72d4477a0a Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 29 Nov 2023 10:58:48 +0000 Subject: [PATCH] Check that attachment is a list --- briar.py | 2 ++ cwtch.py | 2 ++ donate.py | 2 ++ enigma.py | 2 ++ git.py | 2 ++ matrix.py | 2 ++ pgp.py | 2 ++ shares.py | 2 ++ ssb.py | 2 ++ tox.py | 2 ++ xmpp.py | 2 ++ 11 files changed, 22 insertions(+) diff --git a/briar.py b/briar.py index 38be947b7..44444822f 100644 --- a/briar.py +++ b/briar.py @@ -17,6 +17,8 @@ def get_briar_address(actor_json: {}) -> str: """ if not actor_json.get('attachment'): return '' + if not isinstance(actor_json['attachment'], list): + return '' for property_value in actor_json['attachment']: name_value = None if property_value.get('name'): diff --git a/cwtch.py b/cwtch.py index 35e5d6f98..ec59fae11 100644 --- a/cwtch.py +++ b/cwtch.py @@ -17,6 +17,8 @@ def get_cwtch_address(actor_json: {}) -> str: """ if not actor_json.get('attachment'): return '' + if not isinstance(actor_json['attachment'], list): + return '' for property_value in actor_json['attachment']: name_value = None if property_value.get('name'): diff --git a/donate.py b/donate.py index a27fde94b..9fbc264ee 100644 --- a/donate.py +++ b/donate.py @@ -35,6 +35,8 @@ def get_donation_url(actor_json: {}) -> str: """ if not actor_json.get('attachment'): return '' + if not isinstance(actor_json['attachment'], list): + return '' donation_type = _get_donation_types() for property_value in actor_json['attachment']: name_value = None diff --git a/enigma.py b/enigma.py index 7ad34db06..d3547f248 100644 --- a/enigma.py +++ b/enigma.py @@ -17,6 +17,8 @@ def get_enigma_pub_key(actor_json: {}) -> str: """ if not actor_json.get('attachment'): return '' + if not isinstance(actor_json['attachment'], list): + return '' for property_value in actor_json['attachment']: name_value = None if property_value.get('name'): diff --git a/git.py b/git.py index 15b99f4a0..5159f3683 100644 --- a/git.py +++ b/git.py @@ -230,6 +230,8 @@ def get_repo_url(actor_json: {}) -> str: """ if not actor_json.get('attachment'): return '' + if not isinstance(actor_json['attachment'], list): + return '' repo_type = ('github', 'gitlab', 'codeberg', 'launchpad', 'sourceforge', 'bitbucket', 'gitea') for property_value in actor_json['attachment']: diff --git a/matrix.py b/matrix.py index fbde41cda..c2094891b 100644 --- a/matrix.py +++ b/matrix.py @@ -17,6 +17,8 @@ def get_matrix_address(actor_json: {}) -> str: """ if not actor_json.get('attachment'): return '' + if not isinstance(actor_json['attachment'], list): + return '' for property_value in actor_json['attachment']: name_value = None if property_value.get('name'): diff --git a/pgp.py b/pgp.py index 3b7f7ea25..b4a6a522f 100644 --- a/pgp.py +++ b/pgp.py @@ -39,6 +39,8 @@ def get_email_address(actor_json: {}) -> str: """ if not actor_json.get('attachment'): return '' + if not isinstance(actor_json['attachment'], list): + return '' for property_value in actor_json['attachment']: name_value = None if property_value.get('name'): diff --git a/shares.py b/shares.py index 6ab75d3b8..901c359e7 100644 --- a/shares.py +++ b/shares.py @@ -2265,6 +2265,8 @@ def actor_attached_shares(actor_json: {}) -> []: """ if not actor_json.get('attachment'): return [] + if not isinstance(actor_json['attachment'], list): + return [] attached_shares = [] for attach_item in actor_json['attachment']: diff --git a/ssb.py b/ssb.py index 928a495c6..a0571d74d 100644 --- a/ssb.py +++ b/ssb.py @@ -17,6 +17,8 @@ def get_ssb_address(actor_json: {}) -> str: """ if not actor_json.get('attachment'): return '' + if not isinstance(actor_json['attachment'], list): + return '' for property_value in actor_json['attachment']: name_value = None if property_value.get('name'): diff --git a/tox.py b/tox.py index fff619257..64cbed350 100644 --- a/tox.py +++ b/tox.py @@ -17,6 +17,8 @@ def get_tox_address(actor_json: {}) -> str: """ if not actor_json.get('attachment'): return '' + if not isinstance(actor_json['attachment'], list): + return '' for property_value in actor_json['attachment']: name_value = None if property_value.get('name'): diff --git a/xmpp.py b/xmpp.py index 2ed6635e8..77a00cbfa 100644 --- a/xmpp.py +++ b/xmpp.py @@ -17,6 +17,8 @@ def get_xmpp_address(actor_json: {}) -> str: """ if not actor_json.get('attachment'): return '' + if not isinstance(actor_json['attachment'], list): + return '' for property_value in actor_json['attachment']: name_value = None if property_value.get('name'):