1
mirror of https://github.com/rclone/rclone synced 2024-12-05 15:55:18 +01:00
rclone/cmd/serve/sftp/connection_test.go
2019-05-11 23:39:04 +01:00

26 lines
503 B
Go

// +build !plan9
package sftp
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestShellEscape(t *testing.T) {
for i, test := range []struct {
unescaped, escaped string
}{
{"", ""},
{"/this/is/harmless", "/this/is/harmless"},
{"$(rm -rf /)", "\\$\\(rm\\ -rf\\ /\\)"},
{"/test/\n", "/test/'\n'"},
{":\"'", ":\\\"\\'"},
} {
got := shellUnEscape(test.escaped)
assert.Equal(t, test.unescaped, got, fmt.Sprintf("Test %d unescaped = %q", i, test.unescaped))
}
}