FIX: allow for final sigma in suggested usernames ()

Final sigma is not lower cased correctly in Ruby causing issues with routing.

This works around the issue by downcasing all usernames containing a sigma using JS.
This commit is contained in:
Sam 2020-12-23 08:51:36 +11:00 committed by GitHub
parent 758e160862
commit adf8539f64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

@ -110,6 +110,14 @@ module UserNameSuggester
if SiteSetting.unicode_usernames
name.unicode_normalize!
# TODO: Jan 2022, review if still needed
# see: https://meta.discourse.org/t/unicode-username-with-as-the-final-char-leads-to-an-error-loading-profile-page/173182
if name.include?('Σ')
ctx = MiniRacer::Context.new
name = ctx.eval("#{name.to_s.to_json}.toLowerCase()")
ctx.dispose
end
else
name = ActiveSupport::Inflector.transliterate(name)
end

@ -128,6 +128,10 @@ describe UserNameSuggester do
context "with Unicode usernames enabled" do
before { SiteSetting.unicode_usernames = true }
it "normalizes unicode usernames with Σ to lowercase" do
expect(UserNameSuggester.suggest('ΣΣ\'"ΣΣ')).to eq('σς_σς')
end
it "does not transliterate" do
expect(UserNameSuggester.suggest("Jørn")).to eq('Jørn')
end