File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change 99 "net/url"
1010 "os"
1111 "reflect"
12- "regexp"
1312 "strconv"
1413 "strings"
1514 "sync"
@@ -178,8 +177,10 @@ func parseOneOfParam2(s string) []string {
178177 oneofValsCacheRWLock .RUnlock ()
179178 if ! ok {
180179 oneofValsCacheRWLock .Lock ()
181- re := regexp .MustCompile (`'[^']*'|\S+` )
182- vals = re .FindAllString (s , - 1 )
180+ vals = splitParamsRegex .FindAllString (s , - 1 )
181+ for i := 0 ; i < len (vals ); i ++ {
182+ vals [i ] = strings .Replace (vals [i ], "'" , "" , - 1 )
183+ }
183184 oneofValsCache [s ] = vals
184185 oneofValsCacheRWLock .Unlock ()
185186 }
@@ -215,8 +216,7 @@ func isOneOf(fl FieldLevel) bool {
215216 panic (fmt .Sprintf ("Bad field type %T" , field .Interface ()))
216217 }
217218 for i := 0 ; i < len (vals ); i ++ {
218- val := strings .Replace (vals [i ], "'" , "" , - 1 )
219- if val == v {
219+ if vals [i ] == v {
220220 return true
221221 }
222222 }
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ const (
4646 uRLEncodedRegexString = `(%[A-Fa-f0-9]{2})`
4747 hTMLEncodedRegexString = `&#[x]?([0-9a-fA-F]{2})|(>)|(<)|(")|(&)+[;]?`
4848 hTMLRegexString = `<[/]?([a-zA-Z]+).*?>`
49+ splitParamsRegexString = `'[^']*'|\S+`
4950)
5051
5152var (
9293 uRLEncodedRegex = regexp .MustCompile (uRLEncodedRegexString )
9394 hTMLEncodedRegex = regexp .MustCompile (hTMLEncodedRegexString )
9495 hTMLRegex = regexp .MustCompile (hTMLRegexString )
96+ splitParamsRegex = regexp .MustCompile (splitParamsRegexString )
9597)
You can’t perform that action at this time.
0 commit comments