Skip to content

Commit abb108e

Browse files
committed
Fix GetEntry / MLST for servers which send multiple spaces
Some servers seem to send multiple spaces at the end of an MLST response. MLST Workspace 250-Listing Workspace size=0;type=dir;perm=rwx;modify=20250218125218; /Workspace 250 End Before this change this would cause the GetEntry method to return this error. unsupported LIST line This patch ignores zero or more spaces at the start of the MLST response.
1 parent 9064117 commit abb108e

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

conn_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func (mock *ftpMock) listen() {
192192
if cmdParts[1] == "multiline-dir" {
193193
mock.printfLine("250-File data\r\n Type=dir;Size=0; multiline-dir\r\n Modify=20201213202400; multiline-dir\r\n250 End")
194194
} else {
195-
mock.printfLine("250-File data\r\n Type=file;Size=42;Modify=20201213202400; magic-file\r\n \r\n250 End")
195+
mock.printfLine("250-File data\r\n Type=file;Size=42;Modify=20201213202400; magic-file\r\n \r\n250 End")
196196
}
197197
case "NLST":
198198
if mock.dataConn == nil {

ftp.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -780,9 +780,9 @@ func (c *ServerConn) GetEntry(path string) (entry *Entry, err error) {
780780
e := &Entry{}
781781
for _, l := range lines[1 : lc-1] {
782782
// According to RFC 3659, the entry lines must start with a space when passed over the
783-
// control connection. Some servers don't seem to add that space though. Both forms are
784-
// accepted here.
785-
if len(l) > 0 && l[0] == ' ' {
783+
// control connection. Some servers don't seem to add that space though and some servers
784+
// add multiple spaces. All forms are accepted here.
785+
for len(l) > 0 && l[0] == ' ' {
786786
l = l[1:]
787787
}
788788
// Some severs seem to send a blank line at the end which we ignore

0 commit comments

Comments
 (0)