Skip to content

Commit 7e978ff

Browse files
author
Dean Karn
authored
Merge pull request #600 from amiraliucsc/fix/RFC952-host
Fix/rfc952 host
2 parents 957a452 + c7dc881 commit 7e978ff

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

regexes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const (
3636
latitudeRegexString = "^[-+]?([1-8]?\\d(\\.\\d+)?|90(\\.0+)?)$"
3737
longitudeRegexString = "^[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$"
3838
sSNRegexString = `^[0-9]{3}[ -]?(0[1-9]|[1-9][0-9])[ -]?([1-9][0-9]{3}|[0-9][1-9][0-9]{2}|[0-9]{2}[1-9][0-9]|[0-9]{3}[1-9])$`
39-
hostnameRegexStringRFC952 = `^[a-zA-Z][a-zA-Z0-9\-\.]+[a-zA-Z0-9]$` // https://tools.ietf.org/html/rfc952
39+
hostnameRegexStringRFC952 = `^[a-zA-Z]([a-zA-Z0-9\-]+[\.]?)*[a-zA-Z0-9]$` // https://tools.ietf.org/html/rfc952
4040
hostnameRegexStringRFC1123 = `^([a-zA-Z0-9]{1}[a-zA-Z0-9_-]{0,62}){1}(\.[a-zA-Z0-9_]{1}[a-zA-Z0-9_-]{0,62})*?$` // accepts hostname starting with a digit https://tools.ietf.org/html/rfc1123
4141
btcAddressRegexString = `^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$` // bitcoin address
4242
btcAddressUpperRegexStringBech32 = `^BC1[02-9AC-HJ-NP-Z]{7,76}$` // bitcoin bech32 address https://en.bitcoin.it/wiki/Bech32

validator_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7896,6 +7896,11 @@ func TestHostnameRFC952Validation(t *testing.T) {
78967896
{"2001:cdba:0000:0000:0000:0000:3257:9652", false},
78977897
{"2001:cdba:0:0:0:0:3257:9652", false},
78987898
{"2001:cdba::3257:9652", false},
7899+
{"example..........com", false},
7900+
{"1234", false},
7901+
{"abc1234", true},
7902+
{"example. com", false},
7903+
{"ex ample.com", false},
78997904
}
79007905

79017906
validate := New()

0 commit comments

Comments
 (0)