blob: 8c4b80ce1ae1503a8e73884464dae006e25d4234 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.util.publicsuffix;
import android.content.Context;
import android.util.Log;
import org.mozilla.gecko.util.IOUtils;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
class PublicSuffixPatterns {
/** If a hostname is contained as a key in this map, it is a public suffix. */
private static Set<String> EXACT = null;
static synchronized Set<String> getExactSet(Context context) {
if (EXACT != null) {
return EXACT;
}
EXACT = new HashSet<>();
InputStream stream = null;
try {
stream = context.getAssets().open("publicsuffixlist");
BufferedReader reader = new BufferedReader(new InputStreamReader(
new BufferedInputStream(stream)));
String line;
while ((line = reader.readLine()) != null) {
EXACT.add(line);
}
} catch (IOException e) {
Log.e("Patterns", "IOException during loading public suffix list");
} finally {
IOUtils.safeStreamClose(stream);
}
return EXACT;
}
/**
* If a hostname is not a key in the EXCLUDE map, and if removing its
* leftmost component results in a name which is a key in this map, it is a
* public suffix.
*/
static final Set<String> UNDER = new HashSet<>();
static {
UNDER.add("bd");
UNDER.add("magentosite.cloud");
UNDER.add("ke");
UNDER.add("triton.zone");
UNDER.add("compute.estate");
UNDER.add("ye");
UNDER.add("pg");
UNDER.add("kh");
UNDER.add("platform.sh");
UNDER.add("fj");
UNDER.add("ck");
UNDER.add("fk");
UNDER.add("alces.network");
UNDER.add("sch.uk");
UNDER.add("jm");
UNDER.add("mm");
UNDER.add("api.githubcloud.com");
UNDER.add("ext.githubcloud.com");
UNDER.add("0emm.com");
UNDER.add("githubcloudusercontent.com");
UNDER.add("cns.joyent.com");
UNDER.add("bn");
UNDER.add("yokohama.jp");
UNDER.add("nagoya.jp");
UNDER.add("kobe.jp");
UNDER.add("sendai.jp");
UNDER.add("kawasaki.jp");
UNDER.add("sapporo.jp");
UNDER.add("kitakyushu.jp");
UNDER.add("np");
UNDER.add("nom.br");
UNDER.add("er");
UNDER.add("cryptonomic.net");
UNDER.add("gu");
UNDER.add("kw");
UNDER.add("zw");
UNDER.add("mz");
}
/**
* The elements in this map would pass the UNDER test, but are known not to
* be public suffixes and are thus excluded from consideration. Since it
* refers to elements in UNDER of the same type, the type is actually not
* important here. The map is simply used for consistency reasons.
*/
static final Set<String> EXCLUDED = new HashSet<>();
static {
EXCLUDED.add("www.ck");
EXCLUDED.add("city.yokohama.jp");
EXCLUDED.add("city.nagoya.jp");
EXCLUDED.add("city.kobe.jp");
EXCLUDED.add("city.sendai.jp");
EXCLUDED.add("city.kawasaki.jp");
EXCLUDED.add("city.sapporo.jp");
EXCLUDED.add("city.kitakyushu.jp");
EXCLUDED.add("teledata.mz");
}
}
|