email_address 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +5 -2
- data/Rakefile +0 -1
- data/email_address.gemspec +4 -3
- data/lib/email_address/host.rb +5 -7
- data/lib/email_address/local.rb +4 -4
- data/lib/email_address/version.rb +1 -1
- data/test/email_address/test_host.rb +14 -0
- data/test/email_address/test_local.rb +7 -1
- metadata +18 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24b689ac0a16f073c42a43b3f6e49c42e472c1fbef31290fa4c41f26389f3f51
|
4
|
+
data.tar.gz: 7ba8fb68fa0e71a9821d08c8bb5e40ecd5acc625acebc707b4beb4f25240d628
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4514eb116e370d6e3b4bf9ae006178dae86884228ff66053a0ecd8834943d6ab4a3dc8d6ef658c2c080090a1cb28343e3c3eeb1531bc4a3cedb532ac09dee470
|
7
|
+
data.tar.gz: 146e6a106d2f3c3f6c73661b28b4371078d2a529b05fc09d2078aea64f3ce25ff036b91364f244c12fe037ac62ad02f1dbbbeed1d378dfd87a74624714d91d5b
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -429,11 +429,14 @@ matches against the Mail Exchanger (SMTP receivers) hosts defined in
|
|
429
429
|
DNS. If you specify an exchanger pattern, but requires a DNS MX lookup.
|
430
430
|
|
431
431
|
For Rails application, create an initializer file with your default
|
432
|
-
configuration options
|
432
|
+
configuration options.
|
433
|
+
EmailAddress::Config.setting takes a single setting name and value,
|
434
|
+
while EmailAddress::Config.configure takes a hash of multiple settings.
|
433
435
|
|
434
436
|
```ruby
|
435
437
|
# ./config/initializers/email_address.rb
|
436
|
-
EmailAddress::Config.setting( local_format
|
438
|
+
EmailAddress::Config.setting( :local_format, :relaxed )
|
439
|
+
EmailAddress::Config.configure( local_format: :relaxed, ... )
|
437
440
|
EmailAddress::Config.provider(:github,
|
438
441
|
host_match: %w(github.com), local_format: :standard)
|
439
442
|
```
|
data/Rakefile
CHANGED
data/email_address.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "rake"
|
22
22
|
spec.add_development_dependency "minitest", "~> 5.11"
|
23
|
-
spec.add_development_dependency "bundler"
|
23
|
+
spec.add_development_dependency "bundler" #, "~> 1.16.0"
|
24
24
|
if RUBY_PLATFORM == 'java'
|
25
25
|
spec.add_development_dependency "activerecord", "= 4.2.10"
|
26
26
|
spec.add_development_dependency "activerecord-jdbcsqlite3-adapter", '~> 1.3.24'
|
@@ -28,8 +28,9 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency "activerecord", "~> 5.2.0"
|
29
29
|
spec.add_development_dependency "sqlite3"
|
30
30
|
end
|
31
|
-
spec.add_development_dependency "codeclimate-test-reporter"
|
31
|
+
#spec.add_development_dependency "codeclimate-test-reporter"
|
32
|
+
spec.add_development_dependency "simplecov"
|
32
33
|
|
33
34
|
spec.add_dependency "simpleidn"
|
34
|
-
spec.add_dependency "netaddr",
|
35
|
+
spec.add_dependency "netaddr", '>= 2.0.4', '< 3'
|
35
36
|
end
|
data/lib/email_address/host.rb
CHANGED
@@ -288,7 +288,7 @@ module EmailAddress
|
|
288
288
|
|
289
289
|
# Does "example." match any tld?
|
290
290
|
def registration_name_matches?(rule)
|
291
|
-
self.registration_name
|
291
|
+
"#{self.registration_name}." == rule ? true : false
|
292
292
|
end
|
293
293
|
|
294
294
|
# Does "sub.example.com" match ".com" and ".example.com" top level names?
|
@@ -305,8 +305,8 @@ module EmailAddress
|
|
305
305
|
# Requires optionally starts with a "@".
|
306
306
|
def domain_matches?(rule)
|
307
307
|
rule = $1 if rule =~ /\A@(.+)/
|
308
|
-
return rule if File.fnmatch?(rule, self.domain_name)
|
309
|
-
return rule if File.fnmatch?(rule, self.dns_name)
|
308
|
+
return rule if File.fnmatch?(rule, self.domain_name) if self.domain_name
|
309
|
+
return rule if File.fnmatch?(rule, self.dns_name) if self.dns_name
|
310
310
|
false
|
311
311
|
end
|
312
312
|
|
@@ -315,12 +315,10 @@ module EmailAddress
|
|
315
315
|
def ip_matches?(cidr)
|
316
316
|
return false unless self.ip_address
|
317
317
|
return cidr if !cidr.include?("/") && cidr == self.ip_address
|
318
|
-
|
319
|
-
c = NetAddr::CIDR.create(cidr)
|
320
318
|
if cidr.include?(":") && self.ip_address.include?(":")
|
321
|
-
return cidr if
|
319
|
+
return cidr if NetAddr::IPv6Net.parse(cidr).contains(NetAddr::IPv6.parse(self.ip_address))
|
322
320
|
elsif cidr.include?(".") && self.ip_address.include?(".")
|
323
|
-
return cidr if
|
321
|
+
return cidr if NetAddr::IPv4Net.parse(cidr).contains(NetAddr::IPv4.parse(self.ip_address))
|
324
322
|
end
|
325
323
|
false
|
326
324
|
end
|
data/lib/email_address/local.rb
CHANGED
@@ -82,12 +82,12 @@ module EmailAddress
|
|
82
82
|
STANDARD_MAX_SIZE = 64
|
83
83
|
|
84
84
|
# Conventional : word([.-+'_]word)*
|
85
|
-
CONVENTIONAL_MAILBOX_REGEX = /\A [\p{L}\p{N}]+ (?: [\.\-\+\'_] [\p{L}\p{N}]+ )* \z/x
|
86
|
-
CONVENTIONAL_MAILBOX_WITHIN = /[\p{L}\p{N}]+ (?: [\.\-\+\'_] [\p{L}\p{N}]+ )*/x
|
85
|
+
CONVENTIONAL_MAILBOX_REGEX = /\A [\p{L}\p{N}_]+ (?: [\.\-\+\'_] [\p{L}\p{N}_]+ )* \z/x
|
86
|
+
CONVENTIONAL_MAILBOX_WITHIN = /[\p{L}\p{N}_]+ (?: [\.\-\+\'_] [\p{L}\p{N}_]+ )*/x
|
87
87
|
|
88
88
|
# Relaxed: same characters, relaxed order
|
89
|
-
RELAXED_MAILBOX_WITHIN = /[\p{L}\p{N}]+ (?: [\.\-\+\'_]+ [\p{L}\p{N}]+ )*/x
|
90
|
-
RELAXED_MAILBOX_REGEX = /\A [\p{L}\p{N}]+ (?: [\.\-\+\'_]+ [\p{L}\p{N}]+ )* \z/x
|
89
|
+
RELAXED_MAILBOX_WITHIN = /[\p{L}\p{N}_]+ (?: [\.\-\+\'_]+ [\p{L}\p{N}_]+ )*/x
|
90
|
+
RELAXED_MAILBOX_REGEX = /\A [\p{L}\p{N}_]+ (?: [\.\-\+\'_]+ [\p{L}\p{N}_]+ )* \z/x
|
91
91
|
|
92
92
|
# RFC5322 Token: token."token".token (dot-separated tokens)
|
93
93
|
# Quoted Token can also have: SPACE \" \\ ( ) , : ; < > @ [ \ ] .
|
@@ -89,6 +89,20 @@ class TestHost < MiniTest::Test
|
|
89
89
|
assert_equal 'yah*.jp', h.matches?("yah*.jp")
|
90
90
|
end
|
91
91
|
|
92
|
+
def test_ipv4_matches
|
93
|
+
h = EmailAddress::Host.new("[123.123.123.8]", host_allow_ip:true)
|
94
|
+
assert_equal "123.123.123.8", h.ip_address
|
95
|
+
assert_equal false, h.matches?("127.0.0.0/8")
|
96
|
+
assert_equal '123.123.123.0/24', h.matches?("123.123.123.0/24")
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_ipv6_matches
|
100
|
+
h = EmailAddress::Host.new("[IPV6:2001:db8::1]", host_allow_ip:true)
|
101
|
+
assert_equal "2001:db8::1", h.ip_address
|
102
|
+
assert_equal false, h.matches?("2002:db8::/118")
|
103
|
+
assert_equal '2001:db8::/118', h.matches?("2001:db8::/118")
|
104
|
+
end
|
105
|
+
|
92
106
|
def test_regexen
|
93
107
|
assert "asdf.com".match EmailAddress::Host::CANONICAL_HOST_REGEX
|
94
108
|
assert "xn--5ca.com".match EmailAddress::Host::CANONICAL_HOST_REGEX
|
@@ -42,7 +42,7 @@ class TestLocal < MiniTest::Test
|
|
42
42
|
assert EmailAddress::Local.new("first..last", local_format: :relaxed).valid?, "relax.."
|
43
43
|
assert EmailAddress::Local.new("first.-last", local_format: :relaxed).valid?, "relax.-"
|
44
44
|
assert EmailAddress::Local.new("a", local_format: :relaxed).valid?, "relax single"
|
45
|
-
assert
|
45
|
+
assert EmailAddress::Local.new("firstlast_", local_format: :relaxed).valid?, "last_"
|
46
46
|
end
|
47
47
|
|
48
48
|
def test_unicode
|
@@ -99,4 +99,10 @@ class TestLocal < MiniTest::Test
|
|
99
99
|
assert EmailAddress.valid?("xxxxx+subscriber@gmail.com")
|
100
100
|
end
|
101
101
|
|
102
|
+
def test_ending_underscore
|
103
|
+
assert EmailAddress.valid?("name_@icloud.com")
|
104
|
+
assert EmailAddress.valid?("username_@gmail.com")
|
105
|
+
assert EmailAddress.valid?("username_____@gmail.com")
|
106
|
+
end
|
107
|
+
|
102
108
|
end
|
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.1.
|
4
|
+
version: 0.1.12
|
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: 2019-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: activerecord
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: simplecov
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -112,16 +112,22 @@ dependencies:
|
|
112
112
|
name: netaddr
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 2.0.4
|
118
|
+
- - "<"
|
116
119
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
120
|
+
version: '3'
|
118
121
|
type: :runtime
|
119
122
|
prerelease: false
|
120
123
|
version_requirements: !ruby/object:Gem::Requirement
|
121
124
|
requirements:
|
122
|
-
- - "
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: 2.0.4
|
128
|
+
- - "<"
|
123
129
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
130
|
+
version: '3'
|
125
131
|
description: The EmailAddress Gem to work with and validate email addresses.
|
126
132
|
email:
|
127
133
|
- allen.fair@gmail.com
|
@@ -177,8 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
183
|
- !ruby/object:Gem::Version
|
178
184
|
version: '0'
|
179
185
|
requirements: []
|
180
|
-
|
181
|
-
rubygems_version: 2.7.6
|
186
|
+
rubygems_version: 3.0.6
|
182
187
|
signing_key:
|
183
188
|
specification_version: 4
|
184
189
|
summary: This gem provides a ruby language library for working with and validating
|