Pull request: 2582 invalid hostname
Merge in DNS/adguard-home from 2582-invalid-hostname to master Updates #2582. Squashed commit of the following: commit 909598dae00588792b092f89c272c4487ba55dd1 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Mar 4 17:32:58 2021 +0300 all: imp code quality, log changes commit b3b970803709030c48cfe343b88d73524a043de3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Mar 4 16:56:28 2021 +0300 home: add host processing logic
This commit is contained in:
@@ -290,3 +290,29 @@ 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]))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user