reserved_subdomains 0.9.1 → 0.9.2
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/Gemfile.lock +1 -1
- data/lib/regexp_list.yml +20 -19
- data/lib/reserved_subdomains/version.rb +1 -1
- data/lib/reserved_subdomains.rb +8 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e33039af3980603e3c37c92970a0db8bc1a3fdf0e811d88d146b61e776f70164
|
4
|
+
data.tar.gz: 13e040f4e78cb6ef3a413aaddb3705da2d91641e583a21e85846995cc567a661
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2a903a94c4daf8d0017e70f5a6fad7964fffcd8a5ccf0c258ff57c9a5c462fd99dd0bb6e4ba04b00512da7fb1221fcd8e15dabf102711a4b02a3098ab1452f3
|
7
|
+
data.tar.gz: 8ed1973ab97491d72fea7a357ce37b46c85f21f50429c5f90b019ce7b0d23a6905a782036c276ba0c8506b0e42359b10644606432d5e3669156911ef664dec62
|
data/Gemfile.lock
CHANGED
data/lib/regexp_list.yml
CHANGED
@@ -1,20 +1,21 @@
|
|
1
1
|
---
|
2
|
-
-
|
3
|
-
-
|
4
|
-
-
|
5
|
-
-
|
6
|
-
-
|
7
|
-
-
|
8
|
-
-
|
9
|
-
-
|
10
|
-
-
|
11
|
-
-
|
12
|
-
-
|
13
|
-
-
|
14
|
-
-
|
15
|
-
-
|
16
|
-
-
|
17
|
-
-
|
18
|
-
-
|
19
|
-
-
|
20
|
-
-
|
2
|
+
- db[0-9]+
|
3
|
+
- dc[0-9]+
|
4
|
+
- dev[0-9]+
|
5
|
+
- dns[0-9]+
|
6
|
+
- ftp[0-9]+
|
7
|
+
- host[0-9]+
|
8
|
+
- imap[0-9]+
|
9
|
+
- m[0-9]+
|
10
|
+
- mail[0-9]+
|
11
|
+
- mx[0-9]+
|
12
|
+
- ns[0-9]+
|
13
|
+
- server[0-9]+
|
14
|
+
- server-[0-9]+
|
15
|
+
- smtp[0-9]+
|
16
|
+
- static[0-9]+
|
17
|
+
- test[0-9]+
|
18
|
+
- v[0-9\.]+ # versions
|
19
|
+
- vpn[0-9]+
|
20
|
+
- web[0-9]+
|
21
|
+
- ww[a-z0-9-]+ # anything that looks like www might be used for spoofing
|
data/lib/reserved_subdomains.rb
CHANGED
@@ -7,7 +7,10 @@ module ActiveModel
|
|
7
7
|
module Validations
|
8
8
|
class AllowedSubdomainValidator < ::ActiveModel::EachValidator
|
9
9
|
def validate_each(record, attribute, value)
|
10
|
-
|
10
|
+
reserved = exists_in_reserved_list(value)
|
11
|
+
regexp = matches_regexp_list(value)
|
12
|
+
|
13
|
+
if value.present? && ( reserved || regexp)
|
11
14
|
record.errors.add(attribute, :invalid)
|
12
15
|
end
|
13
16
|
end
|
@@ -26,10 +29,12 @@ module ActiveModel
|
|
26
29
|
|
27
30
|
def matches_regexp_list(value)
|
28
31
|
list = load_list('regexp_list.yml')
|
32
|
+
|
29
33
|
list.each do |regexp|
|
30
|
-
return true
|
34
|
+
return true if Regexp.new(regexp).match(value)
|
31
35
|
end
|
32
|
-
|
36
|
+
|
37
|
+
return false
|
33
38
|
end
|
34
39
|
end
|
35
40
|
|