Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Workaround for non-ascii event ids #4241

Merged
merged 1 commit into from
Dec 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/4241.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix exception caused by non-ascii event IDs
4 changes: 3 additions & 1 deletion synapse/state/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)