1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-10 05:52:20 +08:00

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
This commit is contained in:
W. Trevor King
2015-05-16 09:34:08 -07:00
parent 03260a9281
commit 04a969835e

View File

@ -52,10 +52,10 @@ func parseEntry(txt string) (path.Path, error) {
}
func tryParseDnsLink(txt string) (path.Path, error) {
parts := strings.Split(txt, "=")
if len(parts) == 1 || parts[0] != "dnslink" {
return "", errors.New("not a valid dnslink entry")
parts := strings.SplitN(txt, "=", 2)
if len(parts) == 2 && parts[0] == "dnslink" {
return path.ParsePath(parts[1])
}
return path.ParsePath(parts[1])
return "", errors.New("not a valid dnslink entry")
}