Commit 4349b6fa authored by Chris O'Haver's avatar Chris O'Haver Committed by GitHub

dont panic on empty SRV segments (#5173)

Signed-off-by: default avatarChris O'Haver <cohaver@infoblox.com>
parent daace983
...@@ -82,6 +82,9 @@ func parseRequest(name, zone string) (r recordRequest, err error) { ...@@ -82,6 +82,9 @@ func parseRequest(name, zone string) (r recordRequest, err error) {
// stripUnderscore removes a prefixed underscore from s. // stripUnderscore removes a prefixed underscore from s.
func stripUnderscore(s string) string { func stripUnderscore(s string) string {
if len(s) == 0 {
return s
}
if s[0] != '_' { if s[0] != '_' {
return s return s
} }
......
...@@ -23,6 +23,8 @@ func TestParseRequest(t *testing.T) { ...@@ -23,6 +23,8 @@ func TestParseRequest(t *testing.T) {
{"svc.inter.webs.tests.", "....."}, {"svc.inter.webs.tests.", "....."},
// bare pod type // bare pod type
{"pod.inter.webs.tests.", "....."}, {"pod.inter.webs.tests.", "....."},
// SRV request with empty segments
{"..webs.mynamespace.svc.inter.webs.tests.", "...webs.mynamespace.svc"},
} }
for i, tc := range tests { for i, tc := range tests {
m := new(dns.Msg) m := new(dns.Msg)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment