mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
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
This commit is contained in:
parent
7039ece8fb
commit
c03324294d
1
changelog.d/4241.bugfix
Normal file
1
changelog.d/4241.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fix exception caused by non-ascii event IDs
|
@ -298,6 +298,8 @@ def _resolve_normal_events(events, auth_events):
|
|||||||
|
|
||||||
def _ordered_events(events):
|
def _ordered_events(events):
|
||||||
def key_func(e):
|
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)
|
return sorted(events, key=key_func)
|
||||||
|
Loading…
Reference in New Issue
Block a user