Merge commit from fork
* Disallow some special characters in e-mail addresses * Add size limit to email columns
This commit is contained in:
1 parent
fab1e799a6
commit
d6f62f5fa4
3 files changed
+9
-3
No files matched your search
@@ -11,8 +11,14 @@ class EmailAddressValidator < ActiveModel::EachValidator
|
||||
value = value.strip
|
||||
|
||||
address = Mail::Address.new(value)
|
||||
record.errors.add(attribute, :invalid) if address.address != value
|
||||
record.errors.add(attribute, :invalid) if address.address != value || contains_disallowed_characters?(value)
|
||||
rescue Mail::Field::FieldError
|
||||
record.errors.add(attribute, :invalid)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def contains_disallowed_characters?(value)
|
||||
value.include?('%') || value.include?(',') || value.include?('"')
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user