Defect #36969 » 36969-v2.patch
app/models/email_address.rb | ||
---|---|---|
20 | 20 |
class EmailAddress < ActiveRecord::Base |
21 | 21 |
include Redmine::SafeAttributes |
22 | 22 | |
23 |
EMAIL_REGEXP = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+(?:(?:xn--[-a-z0-9]+)|(?:[a-z]{2,})))\z/i |
|
24 | ||
25 | 23 |
belongs_to :user |
26 | 24 | |
27 | 25 |
after_update :destroy_tokens |
... | ... | |
32 | 30 |
after_destroy_commit :deliver_security_notification_destroy |
33 | 31 | |
34 | 32 |
validates_presence_of :address |
35 |
validates_format_of :address, :with => EMAIL_REGEXP, :allow_blank => true |
|
33 |
validates_format_of :address, :with => URI::MailTo::EMAIL_REGEXP, :allow_blank => true
|
|
36 | 34 |
validates_length_of :address, :maximum => User::MAIL_LENGTH_LIMIT, :allow_nil => true |
37 | 35 |
validates_uniqueness_of :address, :case_sensitive => false, |
38 | 36 |
:if => Proc.new {|email| email.address_changed? && email.address.present?} |
app/models/setting.rb | ||
---|---|---|
188 | 188 |
if settings.key?(:mail_from) |
189 | 189 |
begin |
190 | 190 |
mail_from = Mail::Address.new(settings[:mail_from]) |
191 |
raise unless EmailAddress::EMAIL_REGEXP.match?(mail_from.address)
|
|
191 |
raise unless URI::MailTo::EMAIL_REGEXP.match?(mail_from.address)
|
|
192 | 192 |
rescue |
193 | 193 |
messages << [:mail_from, l('activerecord.errors.messages.invalid')] |
194 | 194 |
end |
test/unit/email_address_test.rb | ||
---|---|---|
64 | 64 |
assert email.valid? |
65 | 65 |
end |
66 | 66 |
end |
67 | ||
68 |
def test_should_reject_invalid_email |
|
69 |
assert_not EmailAddress.new(address: 'invalid,email@example.com').valid? |
|
70 |
end |
|
67 | 71 |
end |
- « Previous
- 1
- 2
- Next »