Feature #29208 » 29208-utilize-normalize.patch
app/models/email_address.rb | ||
---|---|---|
36 | 36 |
:if => Proc.new {|email| email.address_changed? && email.address.present?} |
37 | 37 |
validate :validate_email_domain, :if => proc {|email| email.address.present?} |
38 | 38 | |
39 |
safe_attributes 'address' |
|
40 | ||
41 |
def address=(arg) |
|
42 |
normalized_address = arg.to_s.strip |
|
43 | ||
44 |
# Convert internationalized domain name (IDN) to Punycode |
|
45 |
# e.g. 'marie@société.example' => 'marie@xn--socit-esab.example' |
|
39 |
normalizes :address, with: lambda { |address| |
|
40 |
normalized_address = address.to_s.strip |
|
46 | 41 |
local_part, _at, domain = normalized_address.partition('@') |
47 | 42 |
if domain.present? |
43 |
# Convert internationalized domain name (IDN) to Punycode |
|
44 |
# e.g. 'marie@société.example' => 'marie@xn--socit-esab.example' |
|
48 | 45 |
ascii_domain = Addressable::IDNA.to_ascii(domain) |
49 | 46 |
normalized_address = "#{local_part}@#{ascii_domain}" |
50 | 47 |
end |
48 |
normalized_address |
|
49 |
} |
|
51 | 50 | |
52 |
write_attribute(:address, normalized_address) |
|
53 |
end |
|
51 |
safe_attributes 'address' |
|
54 | 52 | |
55 | 53 |
def destroy |
56 | 54 |
if is_default? |
- « Previous
- 1
- …
- 8
- 9
- 10
- Next »