From ddb1464e8ba9c95859e9741824891a34ee2f62ed Mon Sep 17 00:00:00 2001 From: Dmitry Borodaenko Date: Wed, 25 Nov 2020 12:47:05 -0800 Subject: [PATCH 1/2] Strip trailing / from server_url in register_new_matrix_user When server URL provided to register_new_matrix_user includes path component (e.g. "http://localhost:8008/"), the command fails with "ERROR! Received 400 Bad Request". Stripping trailing slash from the server_url command argument makes sure combined endpoint URL remains valid. --- changelog.d/8823.bugfix | 1 + synapse/_scripts/register_new_matrix_user.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog.d/8823.bugfix diff --git a/changelog.d/8823.bugfix b/changelog.d/8823.bugfix new file mode 100644 index 000000000000..0173ec15c881 --- /dev/null +++ b/changelog.d/8823.bugfix @@ -0,0 +1 @@ +Fix register_new_matrix_user failing with Bad Request when trailing slash is included in server URL. diff --git a/synapse/_scripts/register_new_matrix_user.py b/synapse/_scripts/register_new_matrix_user.py index d37ccccd5b70..dfe26dea6dfc 100644 --- a/synapse/_scripts/register_new_matrix_user.py +++ b/synapse/_scripts/register_new_matrix_user.py @@ -37,7 +37,7 @@ def request_registration( exit=sys.exit, ): - url = "%s/_synapse/admin/v1/register" % (server_location,) + url = "%s/_synapse/admin/v1/register" % (server_location.rstrip("/"),) # Get the nonce r = requests.get(url, verify=False) From 061bbb2bf11ce05b262210c23e33c07d9ca10d74 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Thu, 26 Nov 2020 10:56:53 +0000 Subject: [PATCH 2/2] Update 8823.bugfix --- changelog.d/8823.bugfix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/8823.bugfix b/changelog.d/8823.bugfix index 0173ec15c881..74af1c20b659 100644 --- a/changelog.d/8823.bugfix +++ b/changelog.d/8823.bugfix @@ -1 +1 @@ -Fix register_new_matrix_user failing with Bad Request when trailing slash is included in server URL. +Fix `register_new_matrix_user` failing with "Bad Request" when trailing slash is included in server URL. Contributed by @angdraug.