about summary refs log tree commit diff
path: root/app/validators
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-04-08 18:17:22 +0200
committerGitHub <noreply@github.com>2019-04-08 18:17:22 +0200
commitfc2f7ee8710b498c4533e229aff6391396aa7213 (patch)
tree9576b254773166a419b932c50e8f4d354bea73c3 /app/validators
parent30500dff7cbf27fbee6eb45e20cc24ca0b7a9e77 (diff)
parent63837a4b781ad27a4af895b0c983d4aff57d80e3 (diff)
Merge pull request #983 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/validators')
-rw-r--r--app/validators/existing_username_validator.rb10
1 files changed, 2 insertions, 8 deletions
diff --git a/app/validators/existing_username_validator.rb b/app/validators/existing_username_validator.rb
index 4388a0c98..b31d09827 100644
--- a/app/validators/existing_username_validator.rb
+++ b/app/validators/existing_username_validator.rb
@@ -5,16 +5,10 @@ class ExistingUsernameValidator < ActiveModel::EachValidator
     return if value.blank?
 
     if options[:multiple]
-      missing_usernames = value.split(',').map { |username| username unless Account.find_local(username) }.compact
+      missing_usernames = value.split(',').map { |username| username.strip.gsub(/\A@/, '') }.map { |username| username unless Account.find_local(username) }.compact
       record.errors.add(attribute, I18n.t('existing_username_validator.not_found_multiple', usernames: missing_usernames.join(', '))) if missing_usernames.any?
     else
-      record.errors.add(attribute, I18n.t('existing_username_validator.not_found')) unless Account.find_local(value)
+      record.errors.add(attribute, I18n.t('existing_username_validator.not_found')) unless Account.find_local(value.strip.gsub(/\A@/, ''))
     end
   end
-
-  private
-
-  def valid_html?(str)
-    Nokogiri::HTML.fragment(str).to_s == str
-  end
 end