FIX: crawler view with unicode usernames (#27051)

When "unicode_usernames" is enabled, calling the "user_path" helper with a username containing some non ASCII character will break due to the route constraint we have on username.

This fixes the issue by always encoding the username before passing it to the "user_path" helper.

Internal ref - t/127547
This commit is contained in:
Régis Hanol
2024-05-16 17:11:24 +02:00
committed by GitHub
parent 02469d5795
commit 0e9451e93f
4 changed files with 19 additions and 11 deletions

View File

@ -38,6 +38,14 @@ RSpec.describe AboutController do
expect(response.status).to eq(200)
expect(response.body).to include("/u/anadminuser")
end
it "supports unicode usernames" do
SiteSetting.unicode_usernames = true
Fabricate(:admin, username: "martínez")
get "/about", headers: { "HTTP_USER_AGENT" => "Googlebot" }
expect(response.status).to eq(200)
expect(response.body).to include("/u/mart%25C3%25ADnez")
end
end
it "serializes stats when 'Guardian#can_see_about_stats?' is true" do