email_address 0.2.2 → 0.2.3
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 +4 -4
- data/lib/email_address/config.rb +8 -0
- data/lib/email_address/host.rb +3 -1
- data/lib/email_address/version.rb +1 -1
- data/test/email_address/test_address.rb +1 -0
- data/test/email_address/test_host.rb +15 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad468bd4a05991b9a99adbeabd6fdb8c40d965fcdeed1559ddeb95ad6d599d13
|
4
|
+
data.tar.gz: b3b678cf78737eee8ca6a9febb5ff2434edb322b6393383ca7cd50042e66833c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b453716b5ffb47f3cc9a03fd153cb38349d686bfa8830f273c9f9704736ac987c36128c788ab84472c5a3c5d483743f675c1126bf621643fd979f0235bd19f11
|
7
|
+
data.tar.gz: 0e5bdf1545efd28e45da88e600e7e0bf88ddbed11c1e46c516206f5a301b4e7c0a87301daa90141cf91c8403fc1ea8fcb8cd7a725e64b5d9f810428d14115fe8
|
data/lib/email_address/config.rb
CHANGED
@@ -81,6 +81,12 @@ module EmailAddress
|
|
81
81
|
# * host_local: false,
|
82
82
|
# Allow localhost, no domain, or local subdomains.
|
83
83
|
#
|
84
|
+
# * host_fqdn: true
|
85
|
+
# Check if host name is FQDN
|
86
|
+
#
|
87
|
+
# * host_auto_append: true
|
88
|
+
# Append localhost if host is missing
|
89
|
+
#
|
84
90
|
# * address_validation: :parts, :smtp, ->(address) { true }
|
85
91
|
# Address validation policy
|
86
92
|
# :parts Validate local and host.
|
@@ -129,6 +135,8 @@ module EmailAddress
|
|
129
135
|
host_allow_ip: false,
|
130
136
|
host_remove_spaces: false,
|
131
137
|
host_local: false,
|
138
|
+
host_fqdn: true,
|
139
|
+
host_auto_append: true,
|
132
140
|
|
133
141
|
address_validation: :parts, # :parts, :smtp, Proc
|
134
142
|
address_size: 3..254,
|
data/lib/email_address/host.rb
CHANGED
@@ -183,7 +183,7 @@ module EmailAddress
|
|
183
183
|
def fully_qualified_domain_name(host_part)
|
184
184
|
dn = @config[:address_fqdn_domain]
|
185
185
|
if !dn
|
186
|
-
if (host_part.nil? || host_part <= " ") && @config[:host_local]
|
186
|
+
if (host_part.nil? || host_part <= " ") && @config[:host_local] && @config[:host_auto_append]
|
187
187
|
"localhost"
|
188
188
|
else
|
189
189
|
host_part
|
@@ -428,6 +428,8 @@ module EmailAddress
|
|
428
428
|
if localhost?
|
429
429
|
return @config[:host_local] ? true : set_error(:domain_no_localhost)
|
430
430
|
end
|
431
|
+
|
432
|
+
return true if !@config[:host_fqdn]
|
431
433
|
return true if host_name.include?(".") # require FQDN
|
432
434
|
end
|
433
435
|
set_error(:domain_invalid)
|
@@ -103,6 +103,7 @@ class TestAddress < Minitest::Test
|
|
103
103
|
assert_equal false, e.valid? # localhost not allowed by default
|
104
104
|
assert_equal EmailAddress.error("user1"), "Invalid Domain Name"
|
105
105
|
assert_equal EmailAddress.error("user1", host_local: true), "This domain is not configured to accept email"
|
106
|
+
assert_equal EmailAddress.error("user1", host_local: true, host_auto_append: false), "Invalid Domain Name"
|
106
107
|
assert_equal EmailAddress.error("user1@localhost", host_local: true), "This domain is not configured to accept email"
|
107
108
|
assert_equal EmailAddress.error("user1@localhost", host_local: false, host_validation: :syntax), "localhost is not allowed for your domain name"
|
108
109
|
assert_equal EmailAddress.error("user1@localhost", host_local: false, dns_lookup: :off), "localhost is not allowed for your domain name"
|
@@ -68,6 +68,21 @@ class TestHost < MiniTest::Test
|
|
68
68
|
assert_equal true, h.valid?
|
69
69
|
end
|
70
70
|
|
71
|
+
def test_localhost
|
72
|
+
h = EmailAddress::Host.new("localhost", host_local: true, host_validation: :syntax)
|
73
|
+
assert_equal true, h.valid?
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_host_no_dot
|
77
|
+
h = EmailAddress::Host.new("local", host_validation: :syntax)
|
78
|
+
assert_equal false, h.valid?
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_host_no_dot_enable_fqdn
|
82
|
+
h = EmailAddress::Host.new("local", host_fqdn: false, host_validation: :syntax)
|
83
|
+
assert_equal true, h.valid?
|
84
|
+
end
|
85
|
+
|
71
86
|
def test_comment
|
72
87
|
h = EmailAddress::Host.new("(oops)gmail.com")
|
73
88
|
assert_equal "gmail.com", h.to_s
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: email_address
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Allen Fair
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|