summaryrefslogtreecommitdiff
path: root/vendor/github.com/miekg/dns/defaults.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/miekg/dns/defaults.go')
-rw-r--r--vendor/github.com/miekg/dns/defaults.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/vendor/github.com/miekg/dns/defaults.go b/vendor/github.com/miekg/dns/defaults.go
index c1558b79c..6d7e17605 100644
--- a/vendor/github.com/miekg/dns/defaults.go
+++ b/vendor/github.com/miekg/dns/defaults.go
@@ -5,6 +5,7 @@ import (
"net"
"strconv"
"strings"
+ "unicode"
)
const hexDigit = "0123456789abcdef"
@@ -330,8 +331,18 @@ func Fqdn(s string) string {
// CanonicalName returns the domain name in canonical form. A name in canonical
// form is lowercase and fully qualified. See Section 6.2 in RFC 4034.
+// According to the RFC all uppercase US-ASCII letters in the owner name of the
+// RR areeplaced by the corresponding lowercase US-ASCII letters.
func CanonicalName(s string) string {
- return strings.ToLower(Fqdn(s))
+ var result strings.Builder
+ for _, ch := range s {
+ if unicode.IsUpper(ch) && (ch >= 0x00 && ch <= 0x7F) {
+ result.WriteRune(unicode.ToLower(ch))
+ } else {
+ result.WriteRune(ch)
+ }
+ }
+ return Fqdn(result.String())
}
// Copied from the official Go code.