File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
api/internal/plugins/execplugin Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -18,8 +18,11 @@ func ShlexSplit(s string) ([]string, error) {
1818func shlexSplit (s string ) ([]string , error ) {
1919 result := []string {}
2020
21+ // noQuote is used to track if we are not in a quoted
22+ const noQuote = 0
23+
2124 var current strings.Builder
22- var quote rune
25+ var quote rune = noQuote
2326 var escaped bool
2427
2528 for _ , r := range s {
@@ -29,17 +32,17 @@ func shlexSplit(s string) ([]string, error) {
2932 escaped = false
3033 case r == '\\' && quote != '\'' :
3134 escaped = true
32- case (r == '\'' || r == '"' ) && quote == 0 :
35+ case (r == '\'' || r == '"' ) && quote == noQuote :
3336 quote = r
3437 case r == quote :
35- quote = 0
36- case r == '#' && quote == 0 :
38+ quote = noQuote
39+ case r == '#' && quote == noQuote :
3740 // Comment starts, ignore the rest of the line
3841 if current .Len () > 0 {
3942 result = append (result , current .String ())
4043 }
4144 return result , nil
42- case quote == 0 && unicode .IsSpace (r ):
45+ case unicode .IsSpace (r ) && quote == noQuote :
4346 if current .Len () > 0 {
4447 result = append (result , current .String ())
4548 current .Reset ()
@@ -49,7 +52,7 @@ func shlexSplit(s string) ([]string, error) {
4952 }
5053 }
5154
52- if quote != 0 {
55+ if quote != noQuote {
5356 return nil , fmt .Errorf ("unclosed quote in string" )
5457 }
5558 if current .Len () > 0 {
You can’t perform that action at this time.
0 commit comments