Trim trailing whitespace from list commands
Listing a current directory (when the path argument is empty) would send the command "LIST " with trailing whitespace to FTP resulting in 500 errors with Solaris FTP server. This patch fixes that.
This commit is contained in:
@@ -7,6 +7,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -300,3 +302,20 @@ func TestMissingFolderDeleteDirRecur(t *testing.T) {
|
||||
// Wait for the connection to close
|
||||
mock.Wait()
|
||||
}
|
||||
|
||||
func TestListCurrentDir(t *testing.T) {
|
||||
mock, c := openConn(t, "127.0.0.1")
|
||||
|
||||
_, err := c.List("")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "LIST", mock.lastFull, "LIST must not have a trailing whitespace")
|
||||
|
||||
_, err = c.NameList("")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "NLST", mock.lastFull, "NLST must not have a trailing whitespace")
|
||||
|
||||
err = c.Quit()
|
||||
assert.NoError(t, err)
|
||||
|
||||
mock.Wait()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user