diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2022-03-02 08:18:51 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-02 13:18:51 +0000 |
commit | 1103c5fe8a795eafc4aeedc547faa1b68d5a12f5 (patch) | |
tree | 5aa84e6e6b6e8315e9df0f8acd16120a976bef8b /synapse/federation/federation_client.py | |
parent | Move scripts directory inside synapse, exposing as setuptools entry_points (#... (diff) | |
download | synapse-1103c5fe8a795eafc4aeedc547faa1b68d5a12f5.tar.xz |
Check if instances are lists, not sequences. (#12128)
As a str is a sequence, the checks were not granular enough and would allow lists or strings, when only lists were valid.
Diffstat (limited to 'synapse/federation/federation_client.py')
-rw-r--r-- | synapse/federation/federation_client.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/synapse/federation/federation_client.py b/synapse/federation/federation_client.py index 64e595e748..467275b98c 100644 --- a/synapse/federation/federation_client.py +++ b/synapse/federation/federation_client.py @@ -1428,7 +1428,7 @@ class FederationClient(FederationBase): # Validate children_state of the room. children_state = room.pop("children_state", []) - if not isinstance(children_state, Sequence): + if not isinstance(children_state, list): raise InvalidResponseError("'room.children_state' must be a list") if any(not isinstance(e, dict) for e in children_state): raise InvalidResponseError("Invalid event in 'children_state' list") @@ -1440,14 +1440,14 @@ class FederationClient(FederationBase): # Validate the children rooms. children = res.get("children", []) - if not isinstance(children, Sequence): + if not isinstance(children, list): raise InvalidResponseError("'children' must be a list") if any(not isinstance(r, dict) for r in children): raise InvalidResponseError("Invalid room in 'children' list") # Validate the inaccessible children. inaccessible_children = res.get("inaccessible_children", []) - if not isinstance(inaccessible_children, Sequence): + if not isinstance(inaccessible_children, list): raise InvalidResponseError("'inaccessible_children' must be a list") if any(not isinstance(r, str) for r in inaccessible_children): raise InvalidResponseError( @@ -1630,7 +1630,7 @@ def _validate_hierarchy_event(d: JsonDict) -> None: raise ValueError("Invalid event: 'content' must be a dict") via = content.get("via") - if not isinstance(via, Sequence): + if not isinstance(via, list): raise ValueError("Invalid event: 'via' must be a list") if any(not isinstance(v, str) for v in via): raise ValueError("Invalid event: 'via' must be a list of strings") |