namesys/dns: Use SplitN to find dnslink references
RFC 6763 requires printable ASCII except '=' for the key [1], but allows any character including '=' in the value [2]. This patch adjusts our parsing to avoid splitting on '=' in the value, and then ignoring anything after that split. [1]: https://tools.ietf.org/html/rfc6763#section-6.4 [2]: https://tools.ietf.org/html/rfc6763#section-6.5
W. Trevor King committed
May 16, 2015 at 09:34 UTC
04a969835eb06efbb0895a202d7c8d0c3b6c0780
1 file changed
+4
-4
namesys/dns.go
+4
-4
@@ -52,10 +52,10 @@ func parseEntry(txt string) (path.Path, error) {
52
}
53
54
func tryParseDnsLink(txt string) (path.Path, error) {
55
- parts := strings.Split(txt, "=")
56
- if len(parts) == 1 || parts[0] != "dnslink" {
57
- return "", errors.New("not a valid dnslink entry")
55
+ parts := strings.SplitN(txt, "=", 2)
56
+ if len(parts) == 2 && parts[0] == "dnslink" {
57
+ return path.ParsePath(parts[1])
58
}
59
60
- return path.ParsePath(parts[1])
60
+ return "", errors.New("not a valid dnslink entry")
61
}