Browse Source

go.net/publicsuffix: update table to latest list from publicsuffix.org.

Also add a sanity check for the erroneous all-caps "TOKYO" that was
fixed in http://hg.mozilla.org/mozilla-central/rev/e85f83f352de

LGTM=dr.volker.dobler
R=dr.volker.dobler
CC=golang-codereviews
https://golang.org/cl/58890045
Nigel Tao 12 years ago
parent
commit
4c53d991ed
3 changed files with 7178 additions and 6595 deletions
  1. 9 0
      publicsuffix/gen.go
  2. 6758 6565
      publicsuffix/table.go
  3. 411 30
      publicsuffix/table_test.go

+ 9 - 0
publicsuffix/gen.go

@@ -28,6 +28,7 @@ import (
 	"io"
 	"io"
 	"net/http"
 	"net/http"
 	"os"
 	"os"
+	"regexp"
 	"sort"
 	"sort"
 	"strings"
 	"strings"
 
 
@@ -71,6 +72,11 @@ var (
 	labelsMap     = map[string]bool{}
 	labelsMap     = map[string]bool{}
 	rules         = []string{}
 	rules         = []string{}
 
 
+	// validSuffix is used to check that the entries in the public suffix list
+	// are in canonical form (after Punycode encoding). Specifically, capital
+	// letters are not allowed.
+	validSuffix = regexp.MustCompile(`^[a-z0-9_\!\*\-\.]+$`)
+
 	crush  = flag.Bool("crush", true, "make the generated node text as small as possible")
 	crush  = flag.Bool("crush", true, "make the generated node text as small as possible")
 	subset = flag.Bool("subset", false, "generate only a subset of the full table, for debugging")
 	subset = flag.Bool("subset", false, "generate only a subset of the full table, for debugging")
 	url    = flag.String("url",
 	url    = flag.String("url",
@@ -140,6 +146,9 @@ func main1() error {
 		if err != nil {
 		if err != nil {
 			return err
 			return err
 		}
 		}
+		if !validSuffix.MatchString(s) {
+			return fmt.Errorf("bad publicsuffix.org list data: %q", s)
+		}
 
 
 		if *subset {
 		if *subset {
 			switch {
 			switch {

File diff suppressed because it is too large
+ 6758 - 6565
publicsuffix/table.go


File diff suppressed because it is too large
+ 411 - 30
publicsuffix/table_test.go


Some files were not shown because too many files changed in this diff