|
|
@ -9,7 +9,6 @@ import ( |
|
|
|
"net/url" |
|
|
|
"net/url" |
|
|
|
"os" |
|
|
|
"os" |
|
|
|
"reflect" |
|
|
|
"reflect" |
|
|
|
"regexp" |
|
|
|
|
|
|
|
"strconv" |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
"sync" |
|
|
|
"sync" |
|
|
@ -178,8 +177,10 @@ func parseOneOfParam2(s string) []string { |
|
|
|
oneofValsCacheRWLock.RUnlock() |
|
|
|
oneofValsCacheRWLock.RUnlock() |
|
|
|
if !ok { |
|
|
|
if !ok { |
|
|
|
oneofValsCacheRWLock.Lock() |
|
|
|
oneofValsCacheRWLock.Lock() |
|
|
|
re := regexp.MustCompile(`'[^']*'|\S+`) |
|
|
|
vals = splitParamsRegex.FindAllString(s, -1) |
|
|
|
vals = re.FindAllString(s, -1) |
|
|
|
for i := 0; i < len(vals); i++ { |
|
|
|
|
|
|
|
vals[i] = strings.Replace(vals[i], "'", "", -1) |
|
|
|
|
|
|
|
} |
|
|
|
oneofValsCache[s] = vals |
|
|
|
oneofValsCache[s] = vals |
|
|
|
oneofValsCacheRWLock.Unlock() |
|
|
|
oneofValsCacheRWLock.Unlock() |
|
|
|
} |
|
|
|
} |
|
|
@ -215,8 +216,7 @@ func isOneOf(fl FieldLevel) bool { |
|
|
|
panic(fmt.Sprintf("Bad field type %T", field.Interface())) |
|
|
|
panic(fmt.Sprintf("Bad field type %T", field.Interface())) |
|
|
|
} |
|
|
|
} |
|
|
|
for i := 0; i < len(vals); i++ { |
|
|
|
for i := 0; i < len(vals); i++ { |
|
|
|
val := strings.Replace(vals[i], "'", "", -1) |
|
|
|
if vals[i] == v { |
|
|
|
if val == v { |
|
|
|
|
|
|
|
return true |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|