Quick subdomain fix
This commit is contained in:
parent
5e50104d65
commit
eb710716a0
|
|
@ -117,7 +117,7 @@ func (padb *PolicyAuthorityDatabaseImpl) CheckRules(host string, requireWhitelis
|
||||||
for _, r := range rules {
|
for _, r := range rules {
|
||||||
switch r.Type {
|
switch r.Type {
|
||||||
case blacklisted:
|
case blacklisted:
|
||||||
if strings.HasPrefix(host, r.Host) {
|
if strings.HasPrefix(host, r.Host+".") || host == r.Host {
|
||||||
bRules = append(bRules, r.Host)
|
bRules = append(bRules, r.Host)
|
||||||
}
|
}
|
||||||
case whitelisted:
|
case whitelisted:
|
||||||
|
|
|
||||||
|
|
@ -56,4 +56,9 @@ func TestGet(t *testing.T) {
|
||||||
test.AssertNotError(t, err, "Hostname should be whitelisted")
|
test.AssertNotError(t, err, "Hostname should be whitelisted")
|
||||||
err = p.CheckRules("a.a.com", true)
|
err = p.CheckRules("a.a.com", true)
|
||||||
test.AssertError(t, err, "Hostname isn't explicitly whitelisted")
|
test.AssertError(t, err, "Hostname isn't explicitly whitelisted")
|
||||||
|
|
||||||
|
err = p.CheckRules("ab.com", false)
|
||||||
|
test.AssertNotError(t, err, "Hostname should not be blacklisted")
|
||||||
|
err = p.CheckRules(".b.com", false)
|
||||||
|
test.AssertError(t, err, "Hostname should be blacklisted")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue