diff --git a/src/daemon_get.py b/src/daemon_get.py index 599a5101b..844f93133 100644 --- a/src/daemon_get.py +++ b/src/daemon_get.py @@ -3327,6 +3327,13 @@ def daemon_http_get(self) -> None: redirect_headers(self, hashtag_url, None, calling_domain, 303) return + if self.path.startswith('/labels/'): + # TODO + # label_str = self.path.split('/labels/')[1] + self.server.getreq_busy = False + http_404(self, 720) + return + # hashtag search if self.path.startswith('/tags/') or \ (authorized and '/tags/' in self.path): diff --git a/src/daemon_utils.py b/src/daemon_utils.py index 1c798455e..73c1578b9 100644 --- a/src/daemon_utils.py +++ b/src/daemon_utils.py @@ -333,7 +333,7 @@ def update_inbox_queue(self, nickname: str, message_json: {}, if debug: print('INBOX: checking object fields') # check that some fields are a string or list - string_or_list_fields = ('url', 'attributedTo') + string_or_list_fields: dict = ['url'] for check_field in string_or_list_fields: if not message_json['object'].get(check_field): continue @@ -346,6 +346,19 @@ def update_inbox_queue(self, nickname: str, message_json: {}, http_400(self) self.server.postreq_busy = False return 3 + # check that some fields are a string or list or dict + check_field: str = 'attributedTo' + if message_json['object'].get(check_field): + field_value = message_json['object'][check_field] + if not isinstance(field_value, str) and \ + not isinstance(field_value, list) and \ + not isinstance(field_value, dict): + print('INBOX: ' + + check_field + ' should be a string or list or dict ' + + str(message_json['object'][check_field])) + http_400(self) + self.server.postreq_busy = False + return 3 # check that some fields are strings string_fields = ( 'id', 'actor', 'type', 'content', 'published', diff --git a/src/utils.py b/src/utils.py index a7454ddf9..6d728ed07 100644 --- a/src/utils.py +++ b/src/utils.py @@ -132,7 +132,7 @@ def get_person_icon(person_json: {}) -> str: return '' -def get_attributed_to(field: str | list) -> str: +def get_attributed_to(field: str | list | dict) -> str: """Returns the actor """ if isinstance(field, str): @@ -151,6 +151,16 @@ def get_attributed_to(field: str | list) -> str: return attrib['id'] if isinstance(field[0], str): return field[0] + if isinstance(field, dict): + if not (field.get('type') and field.get('id')): + return None + if not (isinstance(field['type'], str) and + isinstance(field['id'], str)): + return None + potential_id: str = remove_id_ending(field['id']) + if field['type'] == 'Person' and \ + resembles_url(potential_id): + return potential_id return None