public_suffix 4.0.0 → 4.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +12 -0
- data/.github/workflows/tests.yml +36 -0
- data/.gitignore +5 -8
- data/.rubocop.yml +2 -2
- data/{.rubocop_defaults.yml → .rubocop_opinionated.yml} +29 -34
- data/.travis.yml +1 -2
- data/CHANGELOG.md +93 -54
- data/Gemfile +6 -3
- data/LICENSE.txt +1 -1
- data/README.md +20 -15
- data/SECURITY.md +104 -0
- data/codecov.yml +14 -0
- data/data/list.txt +322 -142
- data/lib/public_suffix.rb +1 -1
- data/lib/public_suffix/domain.rb +1 -1
- data/lib/public_suffix/errors.rb +1 -1
- data/lib/public_suffix/list.rb +3 -3
- data/lib/public_suffix/rule.rb +2 -2
- data/lib/public_suffix/version.rb +2 -2
- data/public_suffix.gemspec +8 -4
- data/test/acceptance_test.rb +29 -29
- data/test/test_helper.rb +1 -1
- data/test/unit/public_suffix_test.rb +11 -11
- data/test/unit/rule_test.rb +30 -30
- metadata +15 -49
- data/.ruby-gemset +0 -1
data/lib/public_suffix.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
#
|
5
5
|
# Domain name parser based on the Public Suffix List.
|
6
6
|
#
|
7
|
-
# Copyright (c) 2009-
|
7
|
+
# Copyright (c) 2009-2020 Simone Carletti <weppos@weppos.net>
|
8
8
|
|
9
9
|
require_relative "public_suffix/domain"
|
10
10
|
require_relative "public_suffix/version"
|
data/lib/public_suffix/domain.rb
CHANGED
data/lib/public_suffix/errors.rb
CHANGED
data/lib/public_suffix/list.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
#
|
5
5
|
# Domain name parser based on the Public Suffix List.
|
6
6
|
#
|
7
|
-
# Copyright (c) 2009-
|
7
|
+
# Copyright (c) 2009-2020 Simone Carletti <weppos@weppos.net>
|
8
8
|
|
9
9
|
module PublicSuffix
|
10
10
|
|
@@ -48,7 +48,7 @@ module PublicSuffix
|
|
48
48
|
#
|
49
49
|
# @return [PublicSuffix::List]
|
50
50
|
def self.default(**options)
|
51
|
-
@default ||= parse(File.read(DEFAULT_LIST_PATH), options)
|
51
|
+
@default ||= parse(File.read(DEFAULT_LIST_PATH), **options)
|
52
52
|
end
|
53
53
|
|
54
54
|
# Sets the default rule list to +value+.
|
@@ -216,7 +216,7 @@ module PublicSuffix
|
|
216
216
|
|
217
217
|
rules
|
218
218
|
end
|
219
|
-
private :select
|
219
|
+
private :select
|
220
220
|
|
221
221
|
# Gets the default rule.
|
222
222
|
#
|
data/lib/public_suffix/rule.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
#
|
5
5
|
# Domain name parser based on the Public Suffix List.
|
6
6
|
#
|
7
|
-
# Copyright (c) 2009-
|
7
|
+
# Copyright (c) 2009-2020 Simone Carletti <weppos@weppos.net>
|
8
8
|
|
9
9
|
module PublicSuffix
|
10
10
|
|
@@ -22,7 +22,7 @@ module PublicSuffix
|
|
22
22
|
module Rule
|
23
23
|
|
24
24
|
# @api internal
|
25
|
-
Entry = Struct.new(:type, :length, :private)
|
25
|
+
Entry = Struct.new(:type, :length, :private) # rubocop:disable Lint/StructNewOverride
|
26
26
|
|
27
27
|
# = Abstract rule class
|
28
28
|
#
|
@@ -5,9 +5,9 @@
|
|
5
5
|
#
|
6
6
|
# Domain name parser based on the Public Suffix List.
|
7
7
|
#
|
8
|
-
# Copyright (c) 2009-
|
8
|
+
# Copyright (c) 2009-2020 Simone Carletti <weppos@weppos.net>
|
9
9
|
|
10
10
|
module PublicSuffix
|
11
11
|
# The current library version.
|
12
|
-
VERSION = "4.0.
|
12
|
+
VERSION = "4.0.5"
|
13
13
|
end
|
data/public_suffix.gemspec
CHANGED
@@ -12,14 +12,18 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.description = "PublicSuffix can parse and decompose a domain name into top level domain, domain and subdomains."
|
13
13
|
s.licenses = ["MIT"]
|
14
14
|
|
15
|
+
s.metadata = {
|
16
|
+
"bug_tracker_uri" => "https://github.com/weppos/publicsuffix-ruby/issues",
|
17
|
+
"changelog_uri" => "https://github.com/weppos/publicsuffix-ruby/blob/master/CHANGELOG.md",
|
18
|
+
"documentation_uri" => "https://rubydoc.info/gems/#{s.name}/#{s.version}",
|
19
|
+
"homepage_uri" => s.homepage,
|
20
|
+
"source_code_uri" => "https://github.com/weppos/publicsuffix-ruby/tree/v#{s.version}",
|
21
|
+
}
|
22
|
+
|
15
23
|
s.required_ruby_version = ">= 2.3"
|
16
24
|
|
17
25
|
s.require_paths = ["lib"]
|
18
26
|
s.files = `git ls-files`.split("\n")
|
19
27
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
28
|
s.extra_rdoc_files = %w( LICENSE.txt )
|
21
|
-
|
22
|
-
s.add_development_dependency "rake"
|
23
|
-
s.add_development_dependency "mocha"
|
24
|
-
s.add_development_dependency "yard"
|
25
29
|
end
|
data/test/acceptance_test.rb
CHANGED
@@ -5,14 +5,14 @@ require "test_helper"
|
|
5
5
|
class AcceptanceTest < Minitest::Test
|
6
6
|
|
7
7
|
VALID_CASES = [
|
8
|
-
|
9
|
-
|
8
|
+
["example.com", "example.com", [nil, "example", "com"]],
|
9
|
+
["foo.example.com", "example.com", ["foo", "example", "com"]],
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
["verybritish.co.uk", "verybritish.co.uk", [nil, "verybritish", "co.uk"]],
|
12
|
+
["foo.verybritish.co.uk", "verybritish.co.uk", ["foo", "verybritish", "co.uk"]],
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
["parliament.uk", "parliament.uk", [nil, "parliament", "uk"]],
|
15
|
+
["foo.parliament.uk", "parliament.uk", ["foo", "parliament", "uk"]],
|
16
16
|
].freeze
|
17
17
|
|
18
18
|
def test_valid
|
@@ -34,10 +34,10 @@ class AcceptanceTest < Minitest::Test
|
|
34
34
|
|
35
35
|
|
36
36
|
INVALID_CASES = [
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
["nic.bd", PublicSuffix::DomainNotAllowed],
|
38
|
+
[nil, PublicSuffix::DomainInvalid],
|
39
|
+
["", PublicSuffix::DomainInvalid],
|
40
|
+
[" ", PublicSuffix::DomainInvalid],
|
41
41
|
].freeze
|
42
42
|
|
43
43
|
def test_invalid
|
@@ -49,16 +49,16 @@ class AcceptanceTest < Minitest::Test
|
|
49
49
|
|
50
50
|
|
51
51
|
REJECTED_CASES = [
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
52
|
+
["www. .com", true],
|
53
|
+
["foo.co..uk", true],
|
54
|
+
["goo,gle.com", true],
|
55
|
+
["-google.com", true],
|
56
|
+
["google-.com", true],
|
57
|
+
|
58
|
+
# This case was covered in GH-15.
|
59
|
+
# I decided to cover this case because it's not easily reproducible with URI.parse
|
60
|
+
# and can lead to several false positives.
|
61
|
+
["http://google.com", false],
|
62
62
|
].freeze
|
63
63
|
|
64
64
|
def test_rejected
|
@@ -72,9 +72,9 @@ class AcceptanceTest < Minitest::Test
|
|
72
72
|
|
73
73
|
|
74
74
|
CASE_CASES = [
|
75
|
-
|
76
|
-
|
77
|
-
|
75
|
+
["Www.google.com", %w( www google com )],
|
76
|
+
["www.Google.com", %w( www google com )],
|
77
|
+
["www.google.Com", %w( www google com )],
|
78
78
|
].freeze
|
79
79
|
|
80
80
|
def test_ignore_case
|
@@ -90,10 +90,10 @@ class AcceptanceTest < Minitest::Test
|
|
90
90
|
|
91
91
|
|
92
92
|
INCLUDE_PRIVATE_CASES = [
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
93
|
+
["blogspot.com", true, "blogspot.com"],
|
94
|
+
["blogspot.com", false, nil],
|
95
|
+
["subdomain.blogspot.com", true, "blogspot.com"],
|
96
|
+
["subdomain.blogspot.com", false, "subdomain.blogspot.com"],
|
97
97
|
].freeze
|
98
98
|
|
99
99
|
def test_ignore_private
|
@@ -115,14 +115,14 @@ class AcceptanceTest < Minitest::Test
|
|
115
115
|
def valid_uri?(name)
|
116
116
|
uri = URI.parse(name)
|
117
117
|
!uri.host.nil?
|
118
|
-
rescue
|
118
|
+
rescue StandardError
|
119
119
|
false
|
120
120
|
end
|
121
121
|
|
122
122
|
def valid_domain?(name)
|
123
123
|
uri = URI.parse(name)
|
124
124
|
!uri.host.nil? && uri.scheme.nil?
|
125
|
-
rescue
|
125
|
+
rescue StandardError
|
126
126
|
false
|
127
127
|
end
|
128
128
|
|
data/test/test_helper.rb
CHANGED
@@ -141,13 +141,13 @@ class PublicSuffixTest < Minitest::Test
|
|
141
141
|
|
142
142
|
def test_self_normalize
|
143
143
|
[
|
144
|
-
|
145
|
-
|
146
|
-
|
144
|
+
["com", "com"],
|
145
|
+
["example.com", "example.com"],
|
146
|
+
["www.example.com", "www.example.com"],
|
147
147
|
|
148
|
-
|
149
|
-
|
150
|
-
|
148
|
+
["example.com.", "example.com"], # strip FQDN
|
149
|
+
[" example.com ", "example.com"], # strip spaces
|
150
|
+
["Example.COM", "example.com"], # downcase
|
151
151
|
].each do |input, output|
|
152
152
|
assert_equal output, PublicSuffix.normalize(input)
|
153
153
|
end
|
@@ -155,9 +155,9 @@ class PublicSuffixTest < Minitest::Test
|
|
155
155
|
|
156
156
|
def test_normalize_blank
|
157
157
|
[
|
158
|
-
|
159
|
-
|
160
|
-
|
158
|
+
nil,
|
159
|
+
"",
|
160
|
+
" ",
|
161
161
|
].each do |input|
|
162
162
|
error = PublicSuffix.normalize(input)
|
163
163
|
assert_instance_of PublicSuffix::DomainInvalid, error
|
@@ -167,7 +167,7 @@ class PublicSuffixTest < Minitest::Test
|
|
167
167
|
|
168
168
|
def test_normalize_scheme
|
169
169
|
[
|
170
|
-
|
170
|
+
"https://google.com",
|
171
171
|
].each do |input|
|
172
172
|
error = PublicSuffix.normalize(input)
|
173
173
|
assert_instance_of PublicSuffix::DomainInvalid, error
|
@@ -177,7 +177,7 @@ class PublicSuffixTest < Minitest::Test
|
|
177
177
|
|
178
178
|
def test_normalize_leading_dot
|
179
179
|
[
|
180
|
-
|
180
|
+
".google.com",
|
181
181
|
].each do |input|
|
182
182
|
error = PublicSuffix.normalize(input)
|
183
183
|
assert_instance_of PublicSuffix::DomainInvalid, error
|
data/test/unit/rule_test.rb
CHANGED
@@ -70,36 +70,36 @@ class PublicSuffix::RuleBaseTest < Minitest::Test
|
|
70
70
|
|
71
71
|
def test_match
|
72
72
|
[
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
73
|
+
# standard match
|
74
|
+
[PublicSuffix::Rule.factory("uk"), "uk", true],
|
75
|
+
[PublicSuffix::Rule.factory("uk"), "example.uk", true],
|
76
|
+
[PublicSuffix::Rule.factory("uk"), "example.co.uk", true],
|
77
|
+
[PublicSuffix::Rule.factory("co.uk"), "example.co.uk", true],
|
78
|
+
|
79
|
+
# FIXME
|
80
|
+
# [PublicSuffix::Rule.factory("*.com"), "com", false],
|
81
|
+
[PublicSuffix::Rule.factory("*.com"), "example.com", true],
|
82
|
+
[PublicSuffix::Rule.factory("*.com"), "foo.example.com", true],
|
83
|
+
[PublicSuffix::Rule.factory("!example.com"), "com", false],
|
84
|
+
[PublicSuffix::Rule.factory("!example.com"), "example.com", true],
|
85
|
+
[PublicSuffix::Rule.factory("!example.com"), "foo.example.com", true],
|
86
|
+
|
87
|
+
# TLD mismatch
|
88
|
+
[PublicSuffix::Rule.factory("gk"), "example.uk", false],
|
89
|
+
[PublicSuffix::Rule.factory("gk"), "example.co.uk", false],
|
90
|
+
[PublicSuffix::Rule.factory("co.uk"), "uk", false],
|
91
|
+
|
92
|
+
# general mismatch
|
93
|
+
[PublicSuffix::Rule.factory("uk.co"), "example.co.uk", false],
|
94
|
+
[PublicSuffix::Rule.factory("go.uk"), "example.co.uk", false],
|
95
|
+
[PublicSuffix::Rule.factory("co.uk"), "uk", false],
|
96
|
+
|
97
|
+
# partial matches/mismatches
|
98
|
+
[PublicSuffix::Rule.factory("co"), "example.co.uk", false],
|
99
|
+
[PublicSuffix::Rule.factory("example"), "example.uk", false],
|
100
|
+
[PublicSuffix::Rule.factory("le.it"), "example.it", false],
|
101
|
+
[PublicSuffix::Rule.factory("le.it"), "le.it", true],
|
102
|
+
[PublicSuffix::Rule.factory("le.it"), "foo.le.it", true],
|
103
103
|
|
104
104
|
].each do |rule, input, expected|
|
105
105
|
assert_equal expected, rule.match?(input)
|
metadata
CHANGED
@@ -1,57 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: public_suffix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simone Carletti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rake
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: mocha
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: yard
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
11
|
+
date: 2020-05-09 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
55
13
|
description: PublicSuffix can parse and decompose a domain name into top level domain,
|
56
14
|
domain and subdomains.
|
57
15
|
email:
|
@@ -61,10 +19,11 @@ extensions: []
|
|
61
19
|
extra_rdoc_files:
|
62
20
|
- LICENSE.txt
|
63
21
|
files:
|
22
|
+
- ".github/FUNDING.yml"
|
23
|
+
- ".github/workflows/tests.yml"
|
64
24
|
- ".gitignore"
|
65
25
|
- ".rubocop.yml"
|
66
|
-
- ".
|
67
|
-
- ".ruby-gemset"
|
26
|
+
- ".rubocop_opinionated.yml"
|
68
27
|
- ".travis.yml"
|
69
28
|
- ".yardopts"
|
70
29
|
- 2.0-Upgrade.md
|
@@ -73,7 +32,9 @@ files:
|
|
73
32
|
- LICENSE.txt
|
74
33
|
- README.md
|
75
34
|
- Rakefile
|
35
|
+
- SECURITY.md
|
76
36
|
- bin/console
|
37
|
+
- codecov.yml
|
77
38
|
- data/list.txt
|
78
39
|
- lib/public_suffix.rb
|
79
40
|
- lib/public_suffix/domain.rb
|
@@ -107,7 +68,12 @@ files:
|
|
107
68
|
homepage: https://simonecarletti.com/code/publicsuffix-ruby
|
108
69
|
licenses:
|
109
70
|
- MIT
|
110
|
-
metadata:
|
71
|
+
metadata:
|
72
|
+
bug_tracker_uri: https://github.com/weppos/publicsuffix-ruby/issues
|
73
|
+
changelog_uri: https://github.com/weppos/publicsuffix-ruby/blob/master/CHANGELOG.md
|
74
|
+
documentation_uri: https://rubydoc.info/gems/public_suffix/4.0.5
|
75
|
+
homepage_uri: https://simonecarletti.com/code/publicsuffix-ruby
|
76
|
+
source_code_uri: https://github.com/weppos/publicsuffix-ruby/tree/v4.0.5
|
111
77
|
post_install_message:
|
112
78
|
rdoc_options: []
|
113
79
|
require_paths:
|
@@ -123,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
89
|
- !ruby/object:Gem::Version
|
124
90
|
version: '0'
|
125
91
|
requirements: []
|
126
|
-
rubygems_version: 3.
|
92
|
+
rubygems_version: 3.1.2
|
127
93
|
signing_key:
|
128
94
|
specification_version: 4
|
129
95
|
summary: Domain name parser based on the Public Suffix List.
|