Skip to content

Commit

Permalink
Use IsFqdn and Fqdn helper functions more (miekg#892)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmthrgd authored and miekg committed Jan 4, 2019
1 parent b9e1e75 commit 09499bd
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,7 @@ func IsDomainName(s string) (labels int, ok bool) {
return 0, false
}

if !strings.HasSuffix(s, ".") {
s += "."
}
s = Fqdn(s)

// Each dot ends a segment of the name. Except for escaped dots (\.), which
// are normal dots.
Expand Down
2 changes: 1 addition & 1 deletion labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func SplitDomainName(s string) (labels []string) {
fqdnEnd := 0 // offset of the final '.' or the length of the name
idx := Split(s)
begin := 0
if s[len(s)-1] == '.' {
if IsFqdn(s) {
fqdnEnd = len(s) - 1
} else {
fqdnEnd = len(s)
Expand Down
2 changes: 1 addition & 1 deletion msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func packDomainName(s string, msg []byte, off int, compression compressionMap, c
}

// If not fully qualified, error out.
if s[ls-1] != '.' {
if !IsFqdn(s) {
return len(msg), ErrFqdn
}

Expand Down
2 changes: 1 addition & 1 deletion scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ func toAbsoluteName(name, origin string) (absolute string, ok bool) {
}

// check if name is already absolute
if name[len(name)-1] == '.' {
if IsFqdn(name) {
return name, true
}

Expand Down

0 comments on commit 09499bd

Please sign in to comment.