Pull request: 2582 invalid hostname vol.2

Merge in DNS/adguard-home from 2582-invalid-hostname-2 to master

Updates #2582.

Squashed commit of the following:

commit 9d3ceb289e3869b2c3d12e91ec104fb25d7931ee
Merge: 91c68e46 90054974
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Fri Mar 5 19:11:49 2021 +0300

    Merge branch 'master' into 2582-invalid-hostname-2

commit 91c68e468c5f5b12a2fb509ff391133483c9d915
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Fri Mar 5 18:28:14 2021 +0300

    all: mv trimming from home to dhcpd

commit f51faf35288577b6f610f172b26e7ac13aa24f72
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Fri Mar 5 16:28:00 2021 +0300

    home: add more host sanitizings
This commit is contained in:
Eugene Burkov
2021-03-05 19:20:36 +03:00
parent 90054974bc
commit 5aa0ca9319
3 changed files with 11 additions and 40 deletions

View File

@@ -290,29 +290,3 @@ func TestClientsCustomUpstream(t *testing.T) {
assert.Equal(t, 1, len(config.Upstreams))
assert.Equal(t, 1, len(config.DomainReservedUpstreams))
}
func TestProcessHost(t *testing.T) {
const (
name int = iota
host
want
fieldsNum
)
testCases := [][fieldsNum]string{{
name: "valid",
host: "abc",
want: "abc",
}, {
name: "with_trailing_zero_byte",
host: "abc\x00",
want: "abc",
}}
for _, tc := range testCases {
t.Run(tc[name], func(t *testing.T) {
assert.Equal(t, tc[want], sanitizeHost(tc[host]))
})
}
}