Fixes issues with "sota" keyword and call prefix excessive validation

pull/11/head
Jean-Marc MEESSEN 4 years ago committed by GitHub
parent 1280013853
commit 7cc60785a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

2
.gitignore vendored

@ -4,7 +4,7 @@
*.dll *.dll
*.so *.so
*.dylib *.dylib
./FLEcli FLEcli
test/output/temp/* test/output/temp/*
./dist/* ./dist/*

@ -60,6 +60,7 @@ var regexpIsOMname = regexp.MustCompile("^@")
var regexpIsGridLoc = regexp.MustCompile("^#") var regexpIsGridLoc = regexp.MustCompile("^#")
var regexpIsRst = regexp.MustCompile("^[\\d]{1,3}$") var regexpIsRst = regexp.MustCompile("^[\\d]{1,3}$")
var regexpIsFreq = regexp.MustCompile("^[\\d]+\\.[\\d]+$") var regexpIsFreq = regexp.MustCompile("^[\\d]+\\.[\\d]+$")
var regexpIsSotaKeyWord = regexp.MustCompile("(?i)^sota")
// ParseLine cuts a FLE line into useful bits // ParseLine cuts a FLE line into useful bits
func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg string) { func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg string) {
@ -232,7 +233,13 @@ func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg
continue continue
} }
// Is it a WWFF to WWFF reference? // If the "sota" keyword is used, skip it
if regexpIsSotaKeyWord.MatchString(element) {
// this keyword is not supported anymore with FLE 3 and doesn't add any value
continue
}
// Is it a Summit to Summit (sota) reference?
workRef, sotaErr := ValidateSota(element) workRef, sotaErr := ValidateSota(element)
if sotaErr == "" { if sotaErr == "" {
logLine.SOTA = workRef logLine.SOTA = workRef

@ -106,6 +106,11 @@ func TestParseLine(t *testing.T) {
args{inputStr: "1230 on4kjm 5 599", previousLine: LogLine{Mode: "FM", ModeType: "PHONE"}}, args{inputStr: "1230 on4kjm 5 599", previousLine: LogLine{Mode: "FM", ModeType: "PHONE"}},
LogLine{Call: "ON4KJM", Time: "1230", ActualTime: "1230", RSTsent: "55", RSTrcvd: "*599", Mode: "FM", ModeType: "PHONE"}, "Invalid report (599) for PHONE mode ", LogLine{Call: "ON4KJM", Time: "1230", ActualTime: "1230", RSTsent: "55", RSTrcvd: "*599", Mode: "FM", ModeType: "PHONE"}, "Invalid report (599) for PHONE mode ",
}, },
{
"SOTA keywork ",
args{inputStr: "1230 oe6cud/p sota oe/st-309", previousLine: LogLine{Mode: "FM", ModeType: "PHONE"}},
LogLine{Call: "OE6CUD/P", Time: "1230", ActualTime: "1230", RSTsent: "59", RSTrcvd: "59", Mode: "FM", ModeType: "PHONE", SOTA: "OE/ST-309"}, "",
},
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {

@ -50,7 +50,7 @@ func ValidateWwff(inputStr string) (ref, errorMsg string) {
} }
var validCallRegexp = regexp.MustCompile(`[\d]{0,1}[A-Z]{1,2}\d([A-Z]{1,4}|\d{3,3}|\d{1,3}[A-Z])[A-Z]{0,5}`) var validCallRegexp = regexp.MustCompile(`[\d]{0,1}[A-Z]{1,2}\d([A-Z]{1,4}|\d{3,3}|\d{1,3}[A-Z])[A-Z]{0,5}`)
var validPrefixRegexp = regexp.MustCompile(`\A\d?[a-zA-Z]{1,2}$`) var validPrefixRegexp = regexp.MustCompile(`\A[a-zA-Z0-9]{1,3}$`)
// ValidateCall verifies whether the supplied string is a valid callsign. // ValidateCall verifies whether the supplied string is a valid callsign.
// prefix and suffix are not checked for validity // prefix and suffix are not checked for validity

@ -182,7 +182,17 @@ func TestValidateCall(t *testing.T) {
args{sign: "DL/on4KJm/qrpp "}, args{sign: "DL/on4KJm/qrpp "},
"DL/ON4KJM/QRPP", "", "DL/ON4KJM/QRPP", "",
}, },
//Error cases {
"Valid prefix (issue #2)",
args{sign: "e7/z35m/p"},
"E7/Z35M/P", "",
},
{
"Valid E7 callsign (issue #2)",
args{sign: "e7xyz"},
"E7XYZ", "",
},
//*** Error cases *****
{ {
"Pure junk passed", "Pure junk passed",
args{sign: "aaaaaa"}, args{sign: "aaaaaa"},
@ -200,8 +210,8 @@ func TestValidateCall(t *testing.T) {
}, },
{ {
"invalid prefix", "invalid prefix",
args{sign: "xyz/on4kjm"}, args{sign: "xyz4/on4kjm"},
"*XYZ/ON4KJM", "Invalid prefix", "*XYZ4/ON4KJM", "Invalid prefix",
}, },
{ {
"Too many /", "Too many /",

@ -0,0 +1,60 @@
date 2020-07-19
mycall ON6ZQ/P
mysota ON/ON-018
# No 1
# Spotlite
# ON6ZQ/P ON ON-018 7.032 cw
# parking:
# Rue du Broux
# 6940 Durbuy
# 50.326490, 5.532476
cw
30m
1150
55 ix1ihr
f8dgf
56 ea2dt
57 oe6cud/p sota oe/st-309
yo6cfb
1200 e7/z35m/p
dl2hwi
04 oe7phi
04 dl8dxl
05 ok1dpu
ei5hj
iw0hk
g3rtu
07 ok2uz
08 ct1drb
ok2k
11 dd6do
12 oz6abz
13 ea2if/p sota ea2/nv-189
dl5dxs/p oo25
15 dl7uxg
40m
25 dl1fu
26 hb9agh
30 oe8spw
yl3cw
hb9bhu/p sota hb/bl-005
dl7vkd
31 hb9cbr/p sota hb/NE-007
hb9afi/p sota hb/VS-239
m0tcl/p
f6dra
35 g0aol
# Parsing error at line 22: Unable to parse sota
# Parsing error at line 24: Invalid prefix
# Parsing error at line 37: Unable to parse sota
# Parsing error at line 38: Unable to parse oo25
# Parsing error at line 46: Unable to parse sota
# Parsing error at line 48: Unable to parse sota
# Parsing error at line 49: Unable to parse sota
Loading…
Cancel
Save