activemodel-email_address_validator 2.1.0 → 2.1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/ruby.yml +2 -2
- data/CHANGELOG.md +5 -5
- data/activemodel-email_address_validator.gemspec +1 -2
- data/lib/activemodel_email_address_validator/email_address.rb +11 -5
- data/lib/activemodel_email_address_validator/version.rb +1 -1
- data/test/activemodel-email_address_validator/test_email_address.rb +19 -0
- metadata +7 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f6a6ce26e15d4bde1afc0b72c52fdc7cdb2b1bee5c67d559a1e59c26c3f01a9
|
4
|
+
data.tar.gz: bfd1e3d561a487613d71e6ef25c42dc7cff0b7ffb02ed58cc17dddf8f120f061
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b0bf639a327bca0b5ce7448ec1a641f235f33ce4d873c9fd28b1c4f9922600ae4090ebf9317ab946199593e214ea34049eb801e78331b0ec6b2c82bd94ac60b
|
7
|
+
data.tar.gz: d0489b3c90a4735cfc18e4eabb9c9e85e8482d7007646c42c26528e362b26573407d11d283fdc6d91056c830812032496bc51f3e498de1f9a9bd54a9ddef1256
|
data/.github/workflows/ruby.yml
CHANGED
@@ -12,7 +12,7 @@ jobs:
|
|
12
12
|
runs-on: ubuntu-latest
|
13
13
|
strategy:
|
14
14
|
matrix:
|
15
|
-
ruby-version: ['2.4', '2.5', '2.6', '2.7', '3.0', '3.1']
|
15
|
+
ruby-version: ['2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2']
|
16
16
|
|
17
17
|
steps:
|
18
18
|
- uses: actions/checkout@v2
|
@@ -31,7 +31,7 @@ jobs:
|
|
31
31
|
- name: Set up Ruby
|
32
32
|
uses: ruby/setup-ruby@v1
|
33
33
|
with:
|
34
|
-
ruby-version: '3.
|
34
|
+
ruby-version: '3.1'
|
35
35
|
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
36
36
|
- name: Lint
|
37
37
|
run: bundle exec standardrb
|
data/CHANGELOG.md
CHANGED
@@ -5,16 +5,16 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
7
7
|
|
8
|
-
##
|
8
|
+
## [2.1.1]
|
9
9
|
|
10
10
|
### Added
|
11
11
|
|
12
|
-
-
|
12
|
+
- Support for ActiveModel 7.
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
-
|
14
|
+
- Support for Ruby 3.1 and 3.2.
|
17
15
|
|
16
|
+
- Commas are no longer allowed anywhere in an email address. Thanks
|
17
|
+
@prognostikos!
|
18
18
|
|
19
19
|
## [2.1.0]
|
20
20
|
|
@@ -13,10 +13,9 @@ Gem::Specification.new do |spec|
|
|
13
13
|
|
14
14
|
spec.files = `git ls-files -z`.split("\x0")
|
15
15
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
16
|
spec.require_paths = ["lib"]
|
18
17
|
|
19
|
-
spec.add_dependency "activemodel", ">= 4.0", "<
|
18
|
+
spec.add_dependency "activemodel", ">= 4.0", "< 8.0"
|
20
19
|
|
21
20
|
spec.add_development_dependency "bundler", ">= 1.7"
|
22
21
|
spec.add_development_dependency "rake", ">= 10.0"
|
@@ -20,20 +20,26 @@ module ActiveModelEmailAddressValidator
|
|
20
20
|
|
21
21
|
attr_reader :address
|
22
22
|
|
23
|
+
def valid_host?(host)
|
24
|
+
/^([^,. ~]+\.)+[a-z]+$/.match?(host)
|
25
|
+
end
|
26
|
+
|
27
|
+
def valid_user?(user)
|
28
|
+
/^([^.]+\S)*[^.]+$/.match?(user)
|
29
|
+
end
|
30
|
+
|
23
31
|
def valid_using_regex?(regex)
|
24
32
|
address.to_s =~ regex
|
25
33
|
end
|
26
34
|
|
27
35
|
def valid_using_default?
|
28
|
-
return false if
|
29
|
-
email_parts = address.split("@", -1)
|
36
|
+
return false if /(\s|["'<>,])+/.match?(address)
|
30
37
|
|
38
|
+
email_parts = address.split("@", -1)
|
31
39
|
return false unless email_parts.size == 2
|
32
40
|
|
33
41
|
user, host = *email_parts
|
34
|
-
|
35
|
-
return false unless /^([^,. ~]+\.)+[^,. ]+$/.match?(host)
|
36
|
-
true
|
42
|
+
valid_user?(user) && valid_host?(host)
|
37
43
|
end
|
38
44
|
end
|
39
45
|
end
|
@@ -113,6 +113,10 @@ class EmailAddressValidTest < MiniTest::Test
|
|
113
113
|
reject("my@domain.com,")
|
114
114
|
end
|
115
115
|
|
116
|
+
def test_rejects_commas_in_username
|
117
|
+
reject("foo,bar@domain.com")
|
118
|
+
end
|
119
|
+
|
116
120
|
def test_rejects_tildes_in_hostname
|
117
121
|
reject("my@~domain.com")
|
118
122
|
end
|
@@ -121,6 +125,21 @@ class EmailAddressValidTest < MiniTest::Test
|
|
121
125
|
reject("fernandeztorralbofrancisco@sabadellatlantico.")
|
122
126
|
end
|
123
127
|
|
128
|
+
def test_rejects_ip_addresses
|
129
|
+
reject("email@123.123.12.123")
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_rejects_script_injection
|
133
|
+
reject("email_<script></script>_123@example.co.in")
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_rejects_username_with_quotation_mark
|
137
|
+
reject('email"123@example.com')
|
138
|
+
reject('email123@exa"mple.com')
|
139
|
+
reject("email'123@example.com")
|
140
|
+
reject("email123@exa'mple.com")
|
141
|
+
end
|
142
|
+
|
124
143
|
private
|
125
144
|
|
126
145
|
def accept(email_address)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemodel-email_address_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakob Skjerning
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '4.0'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '8.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '4.0'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '8.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: bundler
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -79,6 +79,7 @@ executables: []
|
|
79
79
|
extensions: []
|
80
80
|
extra_rdoc_files: []
|
81
81
|
files:
|
82
|
+
- ".github/dependabot.yml"
|
82
83
|
- ".github/workflows/ruby.yml"
|
83
84
|
- ".gitignore"
|
84
85
|
- CHANGELOG.md
|
@@ -113,11 +114,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
114
|
- !ruby/object:Gem::Version
|
114
115
|
version: '0'
|
115
116
|
requirements: []
|
116
|
-
rubygems_version: 3.
|
117
|
+
rubygems_version: 3.4.3
|
117
118
|
signing_key:
|
118
119
|
specification_version: 4
|
119
120
|
summary: ActiveModel-style email address format validator
|
120
|
-
test_files:
|
121
|
-
- test/activemodel-email_address_validator/test_email_address.rb
|
122
|
-
- test/minitest_helper.rb
|
123
|
-
- test/test_active_model_integration.rb
|
121
|
+
test_files: []
|