Merge pull request #3926 from clchiou/escape-percent-args

stage1: escape '%' in command lines as well as '$'
This commit is contained in:
Luca Bruno
2018-05-07 09:37:06 +00:00
committed by GitHub
2 changed files with 4 additions and 0 deletions

View File

@@ -55,6 +55,7 @@ func execEscape(i int, str string) string {
if i > 0 { // These are escaped only after the first argument
escapeMap[`$`] = `$`
escapeMap[`%`] = `%`
}
escArg := fmt.Sprintf("%q", str)

View File

@@ -55,6 +55,9 @@ func TestQuoteExec(t *testing.T) {
}, {
input: []string{`$path$`, `$argument`},
output: `"$path$" "$$argument"`,
}, {
input: []string{`%path%`, `%argument`},
output: `"%path%" "%%argument"`,
}, {
input: []string{`path`, `Args\nwith\nnewlines`},
output: `"path" "Args\\nwith\\nnewlines"`,