From ac984c744c10baaa6ec41385252881b824b2ded4 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Tue, 15 Aug 2023 12:50:24 +0100 Subject: [PATCH] Disable character range check for user IDs This check is not safe because Synapse hasn't enforced it properly either. Signed-off-by: Neil Alexander --- spec/userid.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/spec/userid.go b/spec/userid.go index 8bd992b0..4bd3ca0a 100644 --- a/spec/userid.go +++ b/spec/userid.go @@ -77,11 +77,18 @@ func parseAndValidateUserID(id string, allowHistoricalIDs bool) (*UserID, error) } func historicallyValidCharacters(localpart string) bool { - for _, r := range localpart { - if r < 0x21 || r == 0x3A || r > 0x7E { - return false + // This check is currently not safe because Synapse has historically + // not enforced these character ranges properly, so there are many + // user IDs out in the wild that fall outside this (like with emoji). + // TODO: This function needs to be room version aware, as this will be + // fixed in a future room version. + /* + for _, r := range localpart { + if r < 0x21 || r == 0x3A || r > 0x7E { + return false + } } - } + */ return true }