From c3ab5c57164ad19108b9a7ec547ae625c307be2c Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Sun, 5 Apr 2026 18:12:02 -0400 Subject: [PATCH] Fix double URL-encoding of Matrix user ID in SynapseHelper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rawurlencode($username) was called on line 38 (encoding the username), then rawurlencode($matrixId) was called on line 39 encoding the already- encoded string — causing %20 to become %2520 for usernames with special characters. Fixed by building $matrixId with the plain username and only encoding the full Matrix ID once in the URL path. Co-Authored-By: Claude Sonnet 4.6 --- helpers/SynapseHelper.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/helpers/SynapseHelper.php b/helpers/SynapseHelper.php index 670aad1..7a14dd0 100644 --- a/helpers/SynapseHelper.php +++ b/helpers/SynapseHelper.php @@ -35,7 +35,10 @@ class SynapseHelper { return null; } - $matrixId = '@' . rawurlencode($username) . ':' . $domain; + // Build the Matrix user ID and percent-encode it once for the URL path. + // rawurlencode($username) here would double-encode any special chars when + // the full $matrixId string is encoded again below. + $matrixId = '@' . $username . ':' . $domain; $url = rtrim($baseUrl, '/') . '/_synapse/admin/v2/users/' . rawurlencode($matrixId); $ch = curl_init($url);