summary refs log tree commit diff
path: root/synapse/crypto
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2020-01-06 15:22:46 +0000
committerGitHub <noreply@github.com>2020-01-06 15:22:46 +0000
commitba897a75903129a453d4fb853190dd31f7d1193b (patch)
tree1cf2bd4dc92a5d825373d6e46d4747814715140c /synapse/crypto
parentAdd experimental 'databases' config (#6580) (diff)
downloadsynapse-ba897a75903129a453d4fb853190dd31f7d1193b.tar.xz
Fix some test failures when frozen_dicts are enabled (#6642)
Fixes #4026
Diffstat (limited to 'synapse/crypto')
-rw-r--r--synapse/crypto/event_signing.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/synapse/crypto/event_signing.py b/synapse/crypto/event_signing.py

index ccaa8a9920..e65bd61d97 100644 --- a/synapse/crypto/event_signing.py +++ b/synapse/crypto/event_signing.py
@@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. - +import collections.abc import hashlib import logging @@ -40,8 +40,11 @@ def check_event_content_hash(event, hash_algorithm=hashlib.sha256): # some malformed events lack a 'hashes'. Protect against it being missing # or a weird type by basically treating it the same as an unhashed event. hashes = event.get("hashes") - if not isinstance(hashes, dict): - raise SynapseError(400, "Malformed 'hashes'", Codes.UNAUTHORIZED) + # nb it might be a frozendict or a dict + if not isinstance(hashes, collections.abc.Mapping): + raise SynapseError( + 400, "Malformed 'hashes': %s" % (type(hashes),), Codes.UNAUTHORIZED + ) if name not in hashes: raise SynapseError(