From 6f531d140b8398a4680567934fe66cb0ca465fbc Mon Sep 17 00:00:00 2001 From: ThibG Date: Thu, 22 Mar 2018 10:45:48 +0100 Subject: Fix MENTION_RE to not match nil usernames (#6862) --- app/models/account.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models') diff --git a/app/models/account.rb b/app/models/account.rb index 14269860f..c88c6ec44 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -48,7 +48,7 @@ class Account < ApplicationRecord USERNAME_RE = /[a-z0-9_]+([a-z0-9_\.]+[a-z0-9_]+)?/i - MENTION_RE = /(?<=^|[^\/[:word:]])@((#{USERNAME_RE}?)(?:@[a-z0-9\.\-]+[a-z0-9]+)?)/i + MENTION_RE = /(?<=^|[^\/[:word:]])@((#{USERNAME_RE})(?:@[a-z0-9\.\-]+[a-z0-9]+)?)/i include AccountAvatar include AccountFinderConcern -- cgit From da70aca28eaa68f21c450c8f7b6ecb6168d29941 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 22 Mar 2018 11:30:22 +0100 Subject: Restore username validation to disallow dots, for now (#6863) Usernames with dots in them do not work with routes, because the dot usually separates the desired page format (e.g. json). I don't want to mess with changing route constraints for this patch release. --- app/models/account.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models') diff --git a/app/models/account.rb b/app/models/account.rb index c88c6ec44..9a83d979f 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -69,7 +69,7 @@ class Account < ApplicationRecord validates :username, uniqueness: { scope: :domain, case_sensitive: true }, if: -> { !local? && will_save_change_to_username? } # Local user validations - validates :username, format: { with: /\A#{USERNAME_RE}\z/i }, length: { maximum: 30 }, if: -> { local? && will_save_change_to_username? } + validates :username, format: { with: /\A[a-z0-9_]+\z/i }, length: { maximum: 30 }, if: -> { local? && will_save_change_to_username? } validates_with UniqueUsernameValidator, if: -> { local? && will_save_change_to_username? } validates_with UnreservedUsernameValidator, if: -> { local? && will_save_change_to_username? } validates :display_name, length: { maximum: 30 }, if: -> { local? && will_save_change_to_display_name? } -- cgit