reverse sorting private params when injecting
This commit is contained in:
parent
b33db29400
commit
65fbfed035
1 changed files with 8 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
package script
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -8,8 +9,14 @@ func Inject(script string, params map[string]string) string {
|
|||
if params == nil {
|
||||
return script
|
||||
}
|
||||
keys := []string{}
|
||||
for k, _ := range params {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Sort(sort.Reverse(sort.StringSlice(keys)))
|
||||
injected := script
|
||||
for k, v := range params {
|
||||
for _, k := range keys {
|
||||
v := params[k]
|
||||
injected = strings.Replace(injected, "$$"+k, v, -1)
|
||||
}
|
||||
return injected
|
||||
|
|
Loading…
Reference in a new issue