dont panic on empty SRV segments

Apply commit 4349b6fa63

Signed-off-by: Arthur Outhenin-Chalandre <arthur@cri.epita.fr>
This commit is contained in:
Arthur Outhenin-Chalandre 2024-11-24 17:59:58 +01:00
parent 3afa45c299
commit 5da8d8ce1b
No known key found for this signature in database
2 changed files with 5 additions and 0 deletions

View File

@ -95,6 +95,9 @@ func parseRequest(name, zone string) (r recordRequest, err error) {
// stripUnderscore removes a prefixed underscore from s.
func stripUnderscore(s string) string {
if len(s) == 0 {
return s
}
if s[0] != '_' {
return s
}

View File

@ -23,6 +23,8 @@ func TestParseRequest(t *testing.T) {
{"svc.inter.webs.tests.", "......"},
// bare pod type
{"pod.inter.webs.tests.", "......"},
// SRV request with empty segments
{"..webs.mynamespace.svc.inter.webs.tests.", "...webs.mynamespace.svc"},
}
for i, tc := range tests {
m := new(dns.Msg)