about summary refs log tree commit diff
path: root/app/validators
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-04-08 15:57:56 +0200
committerThibaut Girka <thib@sitedethib.com>2019-04-08 15:57:56 +0200
commitf5f6d23d554b3a81020feebc65188cc64f644095 (patch)
treeb30197858c2018a32be559f5b4b479571c75dee3 /app/validators
parent30500dff7cbf27fbee6eb45e20cc24ca0b7a9e77 (diff)
parent3f036ac6b8f9919b3b141012db163476f18fe299 (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- config/locales/pl.yml
  Conflict caused by new upstream string too close to glitch-specific
  “flavour” string. Took both strings.
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