提交 04a96983 作者: W. Trevor King

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
上级 03260a92
......@@ -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")
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论