Skip to content

Commit

Permalink
check the TYPE parameter in a case-insensitive manner (#386)
Browse files Browse the repository at this point in the history
* check the TYPE parameter in a case-insensitive manner
* add some tests
  • Loading branch information
drakkan authored Jan 4, 2023
1 parent d33ce00 commit 0b1a04e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions handle_misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ func (c *clientHandler) handleFEAT(param string) error {
}

func (c *clientHandler) handleTYPE(param string) error {
param = strings.ReplaceAll(strings.ToUpper(param), " ", "")
switch param {
case "I", "L8":
c.currentTransferType = TransferTypeBinary
Expand Down
16 changes: 16 additions & 0 deletions handle_misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,22 @@ func TestTYPE(t *testing.T) {
require.NoError(t, err)
require.Equal(t, StatusOK, rc)

rc, _, err = raw.SendCommand("TYPE i")
require.NoError(t, err)
require.Equal(t, StatusOK, rc)

rc, _, err = raw.SendCommand("TYPE a")
require.NoError(t, err)
require.Equal(t, StatusOK, rc)

rc, _, err = raw.SendCommand("TYPE l 8")
require.NoError(t, err)
require.Equal(t, StatusOK, rc)

rc, _, err = raw.SendCommand("TYPE l 7")
require.NoError(t, err)
require.Equal(t, StatusOK, rc)

rc, _, err = raw.SendCommand("TYPE wrong")
require.NoError(t, err)
require.Equal(t, StatusNotImplementedParam, rc)
Expand Down

0 comments on commit 0b1a04e

Please sign in to comment.