8228969: 2019-09-28 public suffix list update

Reviewed-by: mullan
This commit is contained in:
Weijun Wang 2019-10-29 09:34:21 +08:00
parent 26da13e59c
commit 055a49a266
5 changed files with 733 additions and 174 deletions

View File

@ -1,2 +1,2 @@
Github: https://raw.githubusercontent.com/publicsuffix/list/ce0d1a5fba657e55adea3abde4b7f1e50636ff10/public_suffix_list.dat Github: https://raw.githubusercontent.com/publicsuffix/list/33c1c788decfed1052089fa27e3005fe4088dec3/public_suffix_list.dat
Date: 2019-01-28 Date: 2019-09-28

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@ If you do not wish to use the Public Suffix List, you may remove the
The Source Code of this file is available under the The Source Code of this file is available under the
Mozilla Public License, v. 2.0 and is located at Mozilla Public License, v. 2.0 and is located at
https://raw.githubusercontent.com/publicsuffix/list/ce0d1a5fba657e55adea3abde4b7f1e50636ff10/public_suffix_list.dat. https://raw.githubusercontent.com/publicsuffix/list/33c1c788decfed1052089fa27e3005fe4088dec3/public_suffix_list.dat.
If a copy of the MPL was not distributed with this file, you can obtain one If a copy of the MPL was not distributed with this file, you can obtain one
at https://mozilla.org/MPL/2.0/. at https://mozilla.org/MPL/2.0/.

View File

@ -0,0 +1,107 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8228969
* @modules java.base/sun.security.util
* @summary unit test for RegisteredDomain
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileInputStream;
import java.util.Objects;
import java.util.Optional;
import sun.security.util.RegisteredDomain;
public class ParseNames {
public static void main(String[] args) throws Exception {
String dir = System.getProperty("test.src", ".");
File f = new File(dir, "tests.dat");
try (FileInputStream fis = new FileInputStream(f)) {
InputStreamReader r = new InputStreamReader(fis, "UTF-8");
BufferedReader reader = new BufferedReader(r);
String s;
int linenumber = 0;
boolean allTestsPass = true;
while ((s = reader.readLine()) != null) {
linenumber++;
if ("".equals(s) || s.charAt(0) == '#') {
continue;
}
String[] tokens = s.split("\\s+");
if (tokens.length != 3) {
throw new Exception(
String.format("Line %d: test data format incorrect",
linenumber));
}
if (tokens[1].equals("null")) {
tokens[1] = null;
}
if (tokens[2].equals("null")) {
tokens[2] = null;
}
allTestsPass &= runTest(linenumber, tokens[0],
tokens[1], tokens[2]);
}
if (allTestsPass) {
System.out.println("Test passed.");
} else {
throw new Exception("Test failed.");
}
}
}
private static boolean runTest(int lnum, String target,
String expPubSuffix, String expRegDomain) {
System.out.println("target:" + target);
Optional<RegisteredDomain> rd = RegisteredDomain.from(target);
String regName = rd.map(RegisteredDomain::name).orElse(null);
if (!Objects.equals(expRegDomain, regName)) {
System.out.printf(
"Line %d: %s, Expected registered domain: %s, Got: %s\n",
lnum, target, expRegDomain, regName);
return false;
}
if (expRegDomain == null) {
return true;
}
String pubSuffix = rd.map(RegisteredDomain::publicSuffix).orElse(null);
if (!Objects.equals(expPubSuffix, pubSuffix)) {
System.out.printf(
"Line %d: %s, Expected public suffix: %s, Got: %s\n",
lnum, target, expPubSuffix, pubSuffix);
return false;
}
return true;
}
}

View File

@ -0,0 +1,147 @@
# This file is UTF-8 encoded.
#
# Test Expected Expected
# String Public Suffix Registered Domain
#
# ac
foo.ac ac foo.ac
www.foo.ac ac foo.ac
com.ac com.ac null
www.foo.com.ac com.ac foo.com.ac
www.foo.mil.ac mil.ac foo.mil.ac
ac ac null
# Will not match anything in the public suffix list
biff.barr null null
# aero
www.site.gliding.aero gliding.aero site.gliding.aero
media.aero media.aero null
foo.media.aero media.aero foo.media.aero
www.bar.aero aero bar.aero
# aq: domain with only one entry
aq aq null
foo.aq aq foo.aq
www.foo.aq aq foo.aq
# arpa:
1.2.3.4.in-addr.arpa in-addr.arpa 4.in-addr.arpa
arpa arpa null
# au
au au null
com.au com.au null
site.com.au com.au site.com.au
foo.act.edu.au act.edu.au foo.act.edu.au
w.foo.act.edu.au act.edu.au foo.act.edu.au
www.site.act.au act.au site.act.au
# bd consists of only one wildcard
bd null null
foo.bd foo.bd null
site.foo.bd foo.bd site.foo.bd
w.site.foo.bd foo.bd site.foo.bd
# bg has single-letter and single-digit labels
bg bg null
site.bg bg site.bg
site.1.bg 1.bg site.1.bg
site.z.bg z.bg site.z.bg
w.site.z.bg z.bg site.z.bg
# biz
biz biz null
site.biz biz site.biz
w.site.biz biz site.biz
# cn (unicode)
#
foo.mil.cn mil.cn foo.mil.cn
w.foo.mil.cn mil.cn foo.mil.cn
foo.公司.cn 公司.cn foo.公司.cn
w.foo.公司.cn 公司.cn foo.公司.cn
# com
www.foo.com com foo.com
z.www.foo.com com foo.com
com com null
ar.com ar.com null
site.ar.com ar.com site.ar.com
w.site.ar.com ar.com site.ar.com
# ie
www.foo.ie ie foo.ie
www.foo.gov.ie gov.ie foo.gov.ie
# it has a large number of entries
www.gr.it gr.it www.gr.it
www.blahblahblah.it it blahblahblah.it
# jp has a large number of entries, including wildcard and exception rules
jp jp null
foo.jp jp foo.jp
ac.jp ac.jp null
foo.ac.jp ac.jp foo.ac.jp
w.foo.ac.jp ac.jp foo.ac.jp
foo.tokyo.jp tokyo.jp foo.tokyo.jp
w.foo.tokyo.jp tokyo.jp foo.tokyo.jp
p.w.foo.tokyo.jp tokyo.jp foo.tokyo.jp
metro.tokyo.jp tokyo.jp metro.tokyo.jp
w.metro.tokyo.jp tokyo.jp metro.tokyo.jp
foo.kawasaki.jp foo.kawasaki.jp null
w.foo.kawasaki.jp foo.kawasaki.jp w.foo.kawasaki.jp
p.w.foo.kawasaki.jp foo.kawasaki.jp w.foo.kawasaki.jp
city.kawasaki.jp kawasaki.jp city.kawasaki.jp
w.city.kawasaki.jp kawasaki.jp city.kawasaki.jp
# kw
www.example.kw kw example.kw
www.example.com.kw com.kw example.com.kw
# no (three level public prefixes)
foo.no no foo.no
w.foo.no no foo.no
foo.gs.mr.no gs.mr.no foo.gs.mr.no
w.foo.gs.mr.no gs.mr.no foo.gs.mr.no
w.ålgård.no ålgård.no w.ålgård.no
# tr
tr tr null
foo.tr tr foo.tr
site.foo.tr tr foo.tr
www.site.foo.tr tr foo.tr
w.www.site.foo.tr tr foo.tr
nic.tr tr nic.tr
tsk.tr tsk.tr null
one.tsk.tr tsk.tr one.tsk.tr
two.one.tsk.tr tsk.tr one.tsk.tr
# uk
foo.uk uk foo.uk
site.foo.uk uk foo.uk
w.site.foo.uk uk foo.uk
foo.sch.uk foo.sch.uk null
s.foo.sch.uk foo.sch.uk s.foo.sch.uk
w.s.foo.sch.uk foo.sch.uk s.foo.sch.uk
www.nhs.uk nhs.uk www.nhs.uk
www.nls.uk uk nls.uk
# us
site.fl.us fl.us site.fl.us
w.site.fl.us fl.us site.fl.us
foo.us us foo.us
s.k12.ak.us k12.ak.us s.k12.ak.us
w.s.k12.ak.us k12.ak.us s.k12.ak.us
w.s.k12.oh.us k12.oh.us s.k12.oh.us
s.k12.oh.us k12.oh.us s.k12.oh.us
s.pvt.k12.ma.us pvt.k12.ma.us s.pvt.k12.ma.us
w.s.pvt.k12.ma.us pvt.k12.ma.us s.pvt.k12.ma.us
# السعودية
السعودية السعودية null
foo.السعودية السعودية foo.السعودية
w.foo.السعودية السعودية foo.السعودية
## END