From ff65153f7b312427d88fea8b6c6b05461c3696c0 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Mon, 28 Apr 2025 17:29:54 +0200 Subject: [PATCH] Don't check for availability of usernames that aren't ASCII --- crates/matrix-synapse/src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/matrix-synapse/src/lib.rs b/crates/matrix-synapse/src/lib.rs index 1b6627afe..b551c912d 100644 --- a/crates/matrix-synapse/src/lib.rs +++ b/crates/matrix-synapse/src/lib.rs @@ -209,6 +209,12 @@ impl HomeserverConnection for SynapseConnection { err(Debug), )] async fn is_localpart_available(&self, localpart: &str) -> Result { + // Synapse will give us a M_UNKNOWN error if the localpart is not ASCII, + // so we bail out early + if !localpart.is_ascii() { + return Ok(false); + } + let localpart = urlencoding::encode(localpart); let response = self