mirror of
https://github.com/internetee/registry.git
synced 2025-07-27 21:16:12 +02:00
Merge pull request #2609 from internetee/unable-to-create-contact-with-punnycode
Unable to create contact with punnycode
This commit is contained in:
commit
5fc8bc92d4
2 changed files with 15 additions and 0 deletions
|
@ -3,6 +3,8 @@ module Actions
|
|||
extend self
|
||||
|
||||
def run(email:, level:)
|
||||
email = decode_email_punycode(email)
|
||||
|
||||
result = truemail_validate(email: email, level: level)
|
||||
result = validate_for_a_and_aaaa_records(email) if !result && level == :mx
|
||||
result
|
||||
|
@ -32,6 +34,12 @@ module Actions
|
|||
logger.info "Validated #{type} record for #{email}. Validation result - #{result}"
|
||||
end
|
||||
|
||||
def decode_email_punycode(email)
|
||||
local_part, domain = email.split('@')
|
||||
decoded_domain = Addressable::IDNA.to_unicode(domain)
|
||||
"#{local_part}@#{decoded_domain}"
|
||||
end
|
||||
|
||||
def logger
|
||||
@logger ||= Rails.logger
|
||||
end
|
||||
|
|
|
@ -96,6 +96,13 @@ class EmailCheckTest < ActiveSupport::TestCase
|
|||
assert_equal contact_two.validation_events.count, 3
|
||||
end
|
||||
|
||||
def test_should_test_email_with_punnycode
|
||||
email = "info@xn--energiathus-mfb.ee"
|
||||
result = Actions::SimpleMailValidator.run(email: email, level: :mx)
|
||||
|
||||
assert result
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def trumail_result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue