validates_hostname 1.0.13 → 2.0.0
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/.github/workflows/ci.yml +23 -0
- data/.github/workflows/release.yml +37 -0
- data/.github/workflows/tld-update.yml +59 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/.rubocop.yml +35 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +17 -0
- data/Guardfile +12 -0
- data/LICENSE +21 -0
- data/README.md +349 -0
- data/Rakefile +34 -59
- data/config/locales/de.yaml +12 -0
- data/config/locales/en.yaml +12 -0
- data/config/locales/es.yaml +12 -0
- data/config/locales/fr.yaml +12 -0
- data/config/locales/zh.yaml +12 -0
- data/data/tlds.txt +1440 -0
- data/lib/validates_hostname/version.rb +4 -4
- data/lib/validates_hostname.rb +218 -287
- data/validates_hostname.gemspec +18 -39
- metadata +35 -114
- data/CHANGELOG.rdoc +0 -4
- data/MIT-LICENSE +0 -20
- data/README.rdoc +0 -205
metadata
CHANGED
@@ -1,148 +1,70 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validates_hostname
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kim Nøgaard
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
13
|
+
name: activemodel
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
16
|
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
18
|
+
version: '6.0'
|
19
|
+
- - "<"
|
25
20
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: activesupport
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '3.0'
|
21
|
+
version: '8'
|
34
22
|
type: :runtime
|
35
23
|
prerelease: false
|
36
24
|
version_requirements: !ruby/object:Gem::Requirement
|
37
25
|
requirements:
|
38
26
|
- - ">="
|
39
27
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
41
|
-
-
|
42
|
-
name: rspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '3.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '3.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec-rails
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rails
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: sqlite3
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: pry-byebug
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rspec-collection_matchers
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
28
|
+
version: '6.0'
|
29
|
+
- - "<"
|
123
30
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
125
|
-
description: Extension to
|
31
|
+
version: '8'
|
32
|
+
description: Extension to ActiveModel for validating hostnames
|
126
33
|
email: jasen@jasen.dk
|
127
34
|
executables: []
|
128
35
|
extensions: []
|
129
36
|
extra_rdoc_files:
|
130
|
-
-
|
131
|
-
-
|
132
|
-
-
|
37
|
+
- CHANGELOG.md
|
38
|
+
- LICENSE
|
39
|
+
- README.md
|
133
40
|
files:
|
134
|
-
-
|
135
|
-
-
|
136
|
-
-
|
41
|
+
- ".github/workflows/ci.yml"
|
42
|
+
- ".github/workflows/release.yml"
|
43
|
+
- ".github/workflows/tld-update.yml"
|
44
|
+
- ".gitignore"
|
45
|
+
- ".rspec"
|
46
|
+
- ".rubocop.yml"
|
47
|
+
- ".ruby-version"
|
48
|
+
- CHANGELOG.md
|
49
|
+
- Gemfile
|
50
|
+
- Guardfile
|
51
|
+
- LICENSE
|
52
|
+
- README.md
|
137
53
|
- Rakefile
|
54
|
+
- config/locales/de.yaml
|
55
|
+
- config/locales/en.yaml
|
56
|
+
- config/locales/es.yaml
|
57
|
+
- config/locales/fr.yaml
|
58
|
+
- config/locales/zh.yaml
|
59
|
+
- data/tlds.txt
|
138
60
|
- lib/validates_hostname.rb
|
139
61
|
- lib/validates_hostname/version.rb
|
140
62
|
- validates_hostname.gemspec
|
141
63
|
homepage: https://github.com/KimNorgaard/validates_hostname
|
142
64
|
licenses:
|
143
65
|
- MIT
|
144
|
-
metadata:
|
145
|
-
|
66
|
+
metadata:
|
67
|
+
rubygems_mfa_required: 'true'
|
146
68
|
rdoc_options: []
|
147
69
|
require_paths:
|
148
70
|
- lib
|
@@ -150,15 +72,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
72
|
requirements:
|
151
73
|
- - ">="
|
152
74
|
- !ruby/object:Gem::Version
|
153
|
-
version:
|
75
|
+
version: 3.0.0
|
154
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
77
|
requirements:
|
156
78
|
- - ">="
|
157
79
|
- !ruby/object:Gem::Version
|
158
80
|
version: '0'
|
159
81
|
requirements: []
|
160
|
-
rubygems_version: 3.
|
161
|
-
signing_key:
|
82
|
+
rubygems_version: 3.6.9
|
162
83
|
specification_version: 4
|
163
84
|
summary: Checks for valid hostnames
|
164
85
|
test_files: []
|
data/CHANGELOG.rdoc
DELETED
data/MIT-LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2008 Sean Huber (shuber@huberry.com)
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
DELETED
@@ -1,205 +0,0 @@
|
|
1
|
-
= ValidatesHostname
|
2
|
-
|
3
|
-
* Source: https://github.com/KimNorgaard/validates_hostname
|
4
|
-
* Bugs: https://github.com/KimNorgaard/validates_hostname/issues
|
5
|
-
|
6
|
-
== Description
|
7
|
-
|
8
|
-
Extension to ActiveRecord::Base for validating hostnames and domain names.
|
9
|
-
|
10
|
-
|
11
|
-
== Features
|
12
|
-
|
13
|
-
* Adds validation for hostnames to ActiveModel
|
14
|
-
|
15
|
-
* Supports I18n for the error messages
|
16
|
-
|
17
|
-
== Installation
|
18
|
-
|
19
|
-
As plugin (from master)
|
20
|
-
|
21
|
-
rails plugin install git://github.com/KimNorgaard/validates_hostname.git
|
22
|
-
|
23
|
-
As gem
|
24
|
-
|
25
|
-
# in Gemfile
|
26
|
-
gem 'validates_hostname', '~> 1.0'
|
27
|
-
|
28
|
-
# Run bundler
|
29
|
-
$ bundle install
|
30
|
-
|
31
|
-
|
32
|
-
== Validations performed
|
33
|
-
|
34
|
-
* maximum length of hostname is 255 characters
|
35
|
-
|
36
|
-
* maximum length of each hostname label is 63 characters
|
37
|
-
|
38
|
-
* characters allowed in hostname labels are a-z, A-Z, 0-9 and hyphen
|
39
|
-
|
40
|
-
* labels do not begin or end with a hyphen
|
41
|
-
|
42
|
-
* labels do not consist of numeric values only
|
43
|
-
|
44
|
-
|
45
|
-
== Options
|
46
|
-
|
47
|
-
* option to allow for underscores in hostname labels
|
48
|
-
|
49
|
-
* option to require that the last label is a valid TLD (ie. require that the name is a FQDN)
|
50
|
-
|
51
|
-
* option to allow numeric values in the first label of the hostname (exception: the hostname cannot consist of a single numeric label)
|
52
|
-
|
53
|
-
* option to specify a list of valid TLDs
|
54
|
-
|
55
|
-
* options to allow for wildcard hostname in first label (for use with DNS)
|
56
|
-
|
57
|
-
See also http://www.zytrax.com/books/dns/apa/names.html
|
58
|
-
|
59
|
-
|
60
|
-
== How to use
|
61
|
-
|
62
|
-
Simple usage
|
63
|
-
|
64
|
-
class Record < ActiveRecord::Base
|
65
|
-
validates :name, :hostname => true
|
66
|
-
end
|
67
|
-
|
68
|
-
With options
|
69
|
-
|
70
|
-
class Record < ActiveRecord::Base
|
71
|
-
validates :name, :hostname => { OPTIONS }
|
72
|
-
end
|
73
|
-
|
74
|
-
|
75
|
-
== Options and their defaults:
|
76
|
-
|
77
|
-
* :allow_underscore => false
|
78
|
-
|
79
|
-
* :require_valid_tld => false
|
80
|
-
|
81
|
-
* :valid_tlds => Array of allowed TLDs (can only be used with :require_fqdn => true)
|
82
|
-
|
83
|
-
* :allow_numeric_hostname => false
|
84
|
-
|
85
|
-
|
86
|
-
== Examples
|
87
|
-
|
88
|
-
Without options
|
89
|
-
|
90
|
-
class Record < ActiveRecord::Base
|
91
|
-
validates :host, :hostname => true
|
92
|
-
end
|
93
|
-
|
94
|
-
>> @record = Record.new :name => 'horse'
|
95
|
-
>> @record.save
|
96
|
-
=> true
|
97
|
-
|
98
|
-
>> @record2 = Record.new :name => '_horse'
|
99
|
-
>> @record2.save
|
100
|
-
=> false
|
101
|
-
|
102
|
-
With :allow_underscore
|
103
|
-
|
104
|
-
class Record < ActiveRecord::Base
|
105
|
-
validates :name, :hostname => { :allow_underscore => true }
|
106
|
-
end
|
107
|
-
|
108
|
-
>> @record3 = Record.new :name => '_horse'
|
109
|
-
>> @record3.save
|
110
|
-
=> true
|
111
|
-
|
112
|
-
With :require_valid_tld
|
113
|
-
|
114
|
-
class Record < ActiveRecord::Base
|
115
|
-
validates :name, :hostname => { :require_valid_tld => true }
|
116
|
-
end
|
117
|
-
|
118
|
-
>> @record4 = Record.new :name => 'horse'
|
119
|
-
>> @record4.save
|
120
|
-
=> false
|
121
|
-
|
122
|
-
>> @record5 = Record.new :name => 'horse.com'
|
123
|
-
>> @record5.save
|
124
|
-
=> true
|
125
|
-
|
126
|
-
With :valid_tlds
|
127
|
-
|
128
|
-
class Record < ActiveRecord::Base
|
129
|
-
validates :name, :hostname => { :require_valid_tld, :valid_tlds => %w(com org net) }
|
130
|
-
end
|
131
|
-
|
132
|
-
>> @record6 = Record.new :name => 'horse.info'
|
133
|
-
>> @record6.save
|
134
|
-
=> false
|
135
|
-
|
136
|
-
With :allow_numeric_hostname
|
137
|
-
|
138
|
-
class Record < ActiveRecord::Base
|
139
|
-
validates :name, :hostname => { :allow_numeric_hostname => false }
|
140
|
-
end
|
141
|
-
|
142
|
-
>> @record7 = Record.new :name => '123.info'
|
143
|
-
>> @record7.save
|
144
|
-
=> false
|
145
|
-
|
146
|
-
With :allow_wildcard_hostname
|
147
|
-
|
148
|
-
class Record < ActiveRecord::Base
|
149
|
-
validates :name, :hostname => { :allow_wildcard_hostname => true }
|
150
|
-
end
|
151
|
-
|
152
|
-
>> @record8 = Record.new :name => '*.123.info'
|
153
|
-
>> @record8.save
|
154
|
-
=> true
|
155
|
-
|
156
|
-
|
157
|
-
== Extra validators
|
158
|
-
|
159
|
-
A few extra validators are included.
|
160
|
-
|
161
|
-
=== domainname
|
162
|
-
|
163
|
-
* sets require_valid_tld => true
|
164
|
-
|
165
|
-
* sets allow_numeric_hostname => true
|
166
|
-
|
167
|
-
* returns error if there is only one label and this label is numeric
|
168
|
-
|
169
|
-
=== fqdn
|
170
|
-
|
171
|
-
* sets require_valid_tld => true
|
172
|
-
|
173
|
-
=== wildcard
|
174
|
-
|
175
|
-
* sets allow_wildcard_hostname => true
|
176
|
-
|
177
|
-
|
178
|
-
== Error messages
|
179
|
-
|
180
|
-
Using the I18n system to define new defaults:
|
181
|
-
|
182
|
-
en:
|
183
|
-
errors:
|
184
|
-
messages:
|
185
|
-
invalid_label_length: "label must be between 1 and 63 characters long"
|
186
|
-
label_begins_or_ends_with_hyphen: "label begins or ends with a hyphen"
|
187
|
-
hostname_label_is_numeric: "unqualified hostname part cannot consist of numeric values only"
|
188
|
-
single_numeric_hostname_label: "hostnames cannot consist of a single numeric label"
|
189
|
-
label_contains_invalid_characters: "label contains invalid characters (valid characters: [%{valid_chars}])"
|
190
|
-
invalid_hostname_length: "hostname must be between 1 and 255 characters long"
|
191
|
-
tld_is_invalid: "tld of hostname is invalid"
|
192
|
-
|
193
|
-
The %{valid_chars} signifies the range of valid characters allowed in labels.
|
194
|
-
|
195
|
-
It is highly recommended you use the I18n system for error messages.
|
196
|
-
|
197
|
-
|
198
|
-
== Maintainers
|
199
|
-
|
200
|
-
* {Kim Nørgaard}[<jasen@jasen.dk>]
|
201
|
-
|
202
|
-
|
203
|
-
== License
|
204
|
-
|
205
|
-
Copyright (c) 2009-2011 Kim Norgaard, released under the MIT license
|