Skip to content

Commit

Permalink
plusrom hostname validation corrected
Browse files Browse the repository at this point in the history
hyphens are valid characters in hostnames (except for the first character)
  • Loading branch information
JetSetIlly committed Dec 9, 2020
1 parent a81e596 commit 2ce1870
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion hardware/memory/cartridge/plusrom/addrinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,18 @@ func isHostValid(host string) bool {
if len(l) < 1 || len(l) > 63 {
return false
}

// check for valid characters: letters (upper/lower), digits or hyphen
for _, c := range l {
if !unicode.IsLetter(c) && !unicode.IsDigit(c) {
if !unicode.IsLetter(c) && !unicode.IsDigit(c) && c != '-' {
return false
}
}

// a hostname may not start with a hyphen
if l[0] == '-' {
return false
}
}

return true
Expand Down

0 comments on commit 2ce1870

Please sign in to comment.