Quick subdomain fix

This commit is contained in:
Roland Shoemaker 2015-08-18 14:14:26 -07:00
parent 5e50104d65
commit eb710716a0
2 changed files with 6 additions and 1 deletions

View File

@ -117,7 +117,7 @@ func (padb *PolicyAuthorityDatabaseImpl) CheckRules(host string, requireWhitelis
for _, r := range rules {
switch r.Type {
case blacklisted:
if strings.HasPrefix(host, r.Host) {
if strings.HasPrefix(host, r.Host+".") || host == r.Host {
bRules = append(bRules, r.Host)
}
case whitelisted:

View File

@ -56,4 +56,9 @@ func TestGet(t *testing.T) {
test.AssertNotError(t, err, "Hostname should be whitelisted")
err = p.CheckRules("a.a.com", true)
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")
}