summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2018-12-03 11:47:48 +0100
committerAmber Brown <hawkowl@atleastfornow.net>2018-12-03 21:47:48 +1100
commitc03324294d3ff70f44db653ec0d9a6aa588883b4 (patch)
tree3cc73a0d6265e35a936e65feec503ef60078700e /synapse
parentNeilj/fix autojoin (#4223) (diff)
downloadsynapse-c03324294d3ff70f44db653ec0d9a6aa588883b4.tar.xz
Workaround for non-ascii event ids (#4241)
It turns out that we accept events with non-ascii IDs, which would later cause
an explosion during state res.

Fixes #4226
Diffstat (limited to 'synapse')
-rw-r--r--synapse/state/v1.py4
1 files changed, 3 insertions, 1 deletions
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)