fix: sanitize -remote queries (#2603)
This commit is contained in:
1 parent
a9c7e82d24
commit
5932e92888
1 file changed
+10
@@ -15,6 +15,8 @@ import (
|
||||
"strings"
|
||||
|
||||
_ "embed"
|
||||
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
//go:embed doc.txt
|
||||
@@ -343,6 +345,14 @@ Options:
|
||||
log.Fatalf("remote command: %s", err)
|
||||
return
|
||||
}
|
||||
// sanitize untrusted names when writing to a terminal
|
||||
if term.IsTerminal(int(os.Stdout.Fd())) {
|
||||
lines := strings.Split(resp, "\n")
|
||||
for i := range lines {
|
||||
lines[i] = sanitizeName(lines[i])
|
||||
}
|
||||
resp = strings.Join(lines, "\n")
|
||||
}
|
||||
fmt.Print(resp)
|
||||
case *serverMode:
|
||||
if err := os.Chdir(gUser.HomeDir); err != nil {
|
||||
|
||||
Reference in new issue
Block a user