diff --git a/app/logical/user_name_validator.rb b/app/logical/user_name_validator.rb index e6cc3dfb8..815f13163 100644 --- a/app/logical/user_name_validator.rb +++ b/app/logical/user_name_validator.rb @@ -26,7 +26,8 @@ class UserNameValidator < ActiveModel::EachValidator rec.errors.add(attr, "must be more than 1 character long") elsif name.length >= 25 rec.errors.add(attr, "must be less than 25 characters long") - elsif name =~ /[[:space:]]/ + # \p{di} = default ignorable codepoints. Filters out Hangul filler characters (U+115F, U+1160, U+3164, U+FFA0) + elsif name =~ /[[:space:]\p{di}]/ rec.errors.add(attr, "can't contain whitespace") elsif name =~ /\A[[:punct:]]/ rec.errors.add(attr, "can't start with '#{name.first}'") diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 9fb64346d..8d06a1320 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -219,6 +219,11 @@ class UserTest < ActiveSupport::TestCase should_not allow_value("admin").for(:name) should_not allow_value("mod").for(:name) should_not allow_value("moderator").for(:name) + + should_not allow_value("foo_\u115F").for(:name) + should_not allow_value("foo_\u1160").for(:name) + should_not allow_value("foo_\u3164").for(:name) + should_not allow_value("foo_\uFFA0").for(:name) end context "searching for users by name" do