Skip to content

Commit 2ce1870

Browse files
committed
plusrom hostname validation corrected
hyphens are valid characters in hostnames (except for the first character)
1 parent a81e596 commit 2ce1870

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

hardware/memory/cartridge/plusrom/addrinfo.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,18 @@ func isHostValid(host string) bool {
6060
if len(l) < 1 || len(l) > 63 {
6161
return false
6262
}
63+
64+
// check for valid characters: letters (upper/lower), digits or hyphen
6365
for _, c := range l {
64-
if !unicode.IsLetter(c) && !unicode.IsDigit(c) {
66+
if !unicode.IsLetter(c) && !unicode.IsDigit(c) && c != '-' {
6567
return false
6668
}
6769
}
70+
71+
// a hostname may not start with a hyphen
72+
if l[0] == '-' {
73+
return false
74+
}
6875
}
6976

7077
return true

0 commit comments

Comments
 (0)