// Storing cookies under host is a safe stopgap.
return host
}
+ // Only len(suffix) is used to determine the jar key from
+ // here on, so it is okay if psl.PublicSuffix("www.buggy.psl")
+ // returns "com" as the jar key is generated from host.
}
prevDot := strings.LastIndex(host[:i-1], ".")
return host[prevDot+1:]
// testPSL implements PublicSuffixList with just two rules: "co.uk"
// and the default rule "*".
+// The implementation has two intentional bugs:
+// PublicSuffix("www.buggy.psl") == "xy"
+// PublicSuffix("www2.buggy.psl") == "com"
type testPSL struct{}
func (testPSL) String() string {
if d == "co.uk" || strings.HasSuffix(d, ".co.uk") {
return "co.uk"
}
+ if d == "www.buggy.psl" {
+ return "xy"
+ }
+ if d == "www2.buggy.psl" {
+ return "com"
+ }
return d[strings.LastIndex(d, ".")+1:]
}
"co.uk": "co.uk",
"uk": "uk",
"192.168.0.5": "192.168.0.5",
+ "www.buggy.psl": "www.buggy.psl",
+ "www2.buggy.psl": "buggy.psl",
// The following are actual outputs of canonicalHost for
// malformed inputs to canonicalHost (see above).
"": "",