diff options
-rw-r--r-- | changelog.d/4241.bugfix | 1 | ||||
-rw-r--r-- | synapse/state/v1.py | 4 |
2 files changed, 4 insertions, 1 deletions
diff --git a/changelog.d/4241.bugfix b/changelog.d/4241.bugfix new file mode 100644 index 0000000000..1158a5aa16 --- /dev/null +++ b/changelog.d/4241.bugfix @@ -0,0 +1 @@ +Fix exception caused by non-ascii event IDs diff --git a/synapse/state/v1.py b/synapse/state/v1.py index 70a981f4a2..19e091ce3b 100644 --- a/synapse/state/v1.py +++ b/synapse/state/v1.py @@ -298,6 +298,8 @@ def _resolve_normal_events(events, auth_events): def _ordered_events(events): def key_func(e): - return -int(e.depth), hashlib.sha1(e.event_id.encode('ascii')).hexdigest() + # we have to use utf-8 rather than ascii here because it turns out we allow + # people to send us events with non-ascii event IDs :/ + return -int(e.depth), hashlib.sha1(e.event_id.encode('utf-8')).hexdigest() return sorted(events, key=key_func) |