-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decode invalid Matrix user IDs #46
base: develop
Are you sure you want to change the base?
Conversation
The events currently do not show diagnosis for events that went wrong - this is something that should be improved later.
) | ||
localpart | ||
isHistorical ({ localpart } as u) = | ||
String.all validHistoricalLocalpartChar localpart && not (isModern u) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that most user IDs are modern in the Matrix ecosystem, this might compute slightly faster if the second option is computed first.
|
||
|
||
localpartParser : Parser String | ||
localpartParser = | ||
P.chompIf validHistoricalUsernameChar | ||
-- Yes, some illegal users have a zero-length localpart | ||
P.chompWhile (\c -> c /= ':') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that the parser is multiplied, make sure that this passes the tests.
invite.events | ||
} | ||
if UserId.isIllegal event.sender then | ||
invite |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Obsolete: illegal users can no longer appear beyond JSON coders.
As referenced in an issue on the Synapse repository, Synapse servers do not sanitize
sender
fields and hence allow invalid users to exist. Examples are@:example.org
and@🐈:example.org
. As a result, Synapse servers cannot send valid initial sync requests to any user that is a member of any one room where an unsanitized invalid user ID has sent at least one state event.Given that an outright majority of users resides on Synapse and similar servers that permit unsanitized user IDs over federation, this pull request adapts by decoding events individually, and then filtering the ones that contain invalid contents.