FIX: URL encode usernames in grant admin redirect (#34664)

The grant admin action was not properly URL encoding usernames
containing unicode characters, causing broken redirect URLs when
usernames include special characters allowed by the
allowed_unicode_username_characters site setting.


https://meta.discourse.org/t/granting-admin-rights-fails-for-usernames-with-special-characters-when-admin-account-has-2fa-enabled/378063
This commit is contained in:
Krzysztof Kotlarek
2025-10-13 09:49:23 +08:00
committed by GitHub
parent 288e2e1ccb
commit 4cf4f9fa61
2 changed files with 14 additions and 1 deletions
+2 -1
View File
@@ -16,7 +16,8 @@ module SecondFactor::Actions
callback_params: {
user_id: user.id,
},
redirect_url: admin_user_show_path(id: user.id, username: user.username),
redirect_url:
CGI.unescape(admin_user_show_path(id: user.id, username: CGI.escape(user.username))),
description: description,
}
end