Skip to content
Snippets Groups Projects
Commit c0332429 authored by Richard van der Hoff's avatar Richard van der Hoff Committed by Amber Brown
Browse files

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
parent 7039ece8
No related branches found
No related tags found
No related merge requests found
Fix exception caused by non-ascii event IDs
......@@ -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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment