email_address 0.2.9 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f208df87862abc3af2936e9f6780e12409ed4430353125829cdeed515bffe044
4
- data.tar.gz: 9c5573440c5759d71d172e2a534b14050375a0a66351c01ddafabd6a5db5cb26
3
+ metadata.gz: 0377bf1111952194f08e39cbec4f7e27590dc0937e3c64157771ba414b846ed5
4
+ data.tar.gz: 194c0e95dea6ad0982afc93b25554cc0f9d0754a84c9e9e8de19b370500e62b5
5
5
  SHA512:
6
- metadata.gz: 67fd95a7991cd3c6acd3cc0a0f955de58597435297ccf7a7edd57e92cf9aed9b4cd523655bfb9775cd03f477c4a06d86f7195fb5b7a257fde96dcdc36ca21cca
7
- data.tar.gz: 437e9173744dccba78cef4301e3a4b107a977017cb58d273896c5ea4c05e41389c3b638819767658d03878f808e09e06b480a33ce0ca7ef446641d98a20475f8
6
+ metadata.gz: f50b770ea1202e8bdf87a75d50872c436afde829f1c2de24bcaa467db17ad26b40b2fb457d6011f2be68d5410e59e8f985a705695197cafb14edd8ba0fb4ab50
7
+ data.tar.gz: 3dffdd1c4bef9ada139fb82b1970d6bdac19c898912bf053539fb1af5887003788957dabc15fb2cabe3302fc4295a6694588540b391a5ad6d2ee467a2297ac6b
@@ -446,23 +446,31 @@ module EmailAddress
446
446
  # is a potentially valid IP address. It does not check if the address
447
447
  # is reachable.
448
448
  def valid_ip?
449
+ bool = true
449
450
  if !@config[:host_allow_ip]
450
451
  bool = set_error(:ip_address_forbidden)
451
- elsif ip_address.include?(":")
452
- bool = ip_address.match(Resolv::IPv6::Regex) ? true : set_error(:ipv6_address_invalid)
453
- elsif ip_address.include?(".")
454
- bool = ip_address.match(Resolv::IPv4::Regex) ? true : set_error(:ipv4_address_invalid)
452
+ else
453
+ _ = IPAddr.new(ip_address) # Rescue invalid address
455
454
  end
456
455
  if bool && (localhost? && !@config[:host_local])
457
456
  bool = set_error(:ip_address_no_localhost)
458
457
  end
459
458
  bool
459
+ rescue IPAddr::InvalidAddressError
460
+ if ip_address.include?(":")
461
+ set_error(:ipv6_address_invalid)
462
+ else
463
+ set_error(:ipv4_address_invalid)
464
+ end
465
+ bool = false
460
466
  end
461
467
 
462
468
  def localhost?
463
469
  return true if host_name == "localhost"
464
470
  return false unless ip_address
465
471
  IPAddr.new(ip_address).loopback?
472
+ rescue IPAddr::InvalidAddressError
473
+ return false
466
474
  end
467
475
 
468
476
  # Connects to host to test it can receive email. This should NOT be performed
@@ -1,3 +1,3 @@
1
1
  module EmailAddress
2
- VERSION = "0.2.9"
2
+ VERSION = "0.2.10"
3
3
  end
@@ -170,4 +170,9 @@ class TestHost < MiniTest::Test
170
170
  def test_mx_only_domain
171
171
  assert EmailAddress::Host.new("mail.usqrl.com").valid?
172
172
  end
173
+
174
+ def test_bad_ipv6_host
175
+ assert EmailAddress.valid?("test@[IPv6:1111:2222:3333:4444:5555:6666:7777:88]", host_allow_ip: true)
176
+ assert !EmailAddress.valid?("test@[IPv6:1111:2222:3333:4444:5555:6666::7777:88]", host_allow_ip: true)
177
+ end
173
178
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: email_address
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Allen Fair
@@ -263,7 +263,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
263
263
  - !ruby/object:Gem::Version
264
264
  version: '0'
265
265
  requirements: []
266
- rubygems_version: 4.0.6
266
+ rubygems_version: 4.0.20
267
267
  specification_version: 4
268
268
  summary: This gem provides a ruby language library for working with and validating
269
269
  email addresses. By default, it validates against conventional usage, the format