Repository: rclone/rclone (language: go)

Issue:
[FTP] ls commands returns an empty list on "Microsoft FTP Service" servers
**What is the problem you are having with Rclone?**
Rclone ls doesn't returns anything

**What is your rclone version (output from `rclone version`)**
(I'm using the docker version)
```
rclone v1.68.2
- os/version: alpine 3.20.3 (64 bit)
- os/kernel: 5.15.167.4-microsoft-standard-WSL2 (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.23.3
- go/linking: static
- go/tags: none
```

**Which cloud storage system are you using? (e.g. Google Drive)**
`FTP`

**The command you were trying to run (e.g. `rclone copy /tmp remote:tmp`)**
`rclone.exe ls ftp:`

**Log with ---dump bodies**
```
2024/12/03 15:57:29 DEBUG : rclone: Version "v1.68.2" starting with parameters ["rclone" "lsd" "myftp:" "-vvv" "--dump" "bodies" "--ftp-concurrency=1"]
2024/12/03 15:57:29 DEBUG : ftp://ftp.myftp.pt:21: Connecting to FTP server
2024/12/03 15:57:29 DEBUG : ftp://ftp.myftp.pt:21: dial("tcp","ftp.myftp.pt:21")
2024/12/03 15:57:37 DEBUG : ftp://ftp.myftp.pt:21: > dial: conn=*fshttp.timeoutConn, err=<nil>
2024/12/03 15:57:37 DEBUG : FTP Rx: "220 Microsoft FTP Service"
2024/12/03 15:57:37 DEBUG : FTP Tx: "USER anonymous"
2024/12/03 15:57:37 DEBUG : FTP Rx: "331 Anonymous access allowed, send identity (e-mail name) as password."
2024/12/03 15:57:37 DEBUG : FTP Tx: PASS *****
2024/12/03 15:57:37 DEBUG : FTP Rx: "230 User logged in."
2024/12/03 15:57:37 DEBUG : FTP Tx: "FEAT"
2024/12/03 15:57:37 DEBUG : FTP Rx: "211-Extended features supported:"
2024/12/03 15:57:37 DEBUG : FTP Rx: " LANG EN*"
2024/12/03 15:57:37 DEBUG : FTP Rx: " UTF8"
2024/12/03 15:57:37 DEBUG : FTP Rx: " AUTH TLS;TLS-C;SSL;TLS-P;"
2024/12/03 15:57:37 DEBUG : FTP Rx: " PBSZ"
2024/12/03 15:57:37 DEBUG : FTP Rx: " PROT C;P;"
2024/12/03 15:57:37 DEBUG : FTP Rx: " CCC"
2024/12/03 15:57:37 DEBUG : FTP Rx: " HOST"
2024/12/03 15:57:37 DEBUG : FTP Rx: " SIZE"
2024/12/03 15:57:37 DEBUG : FTP Rx: " MDTM"
2024/12/03 15:57:37 DEBUG : FTP Rx: " REST STREAM"
2024/12/03 15:57:37 DEBUG : FTP Rx: "211 END"
2024/12/03 15:57:37 DEBUG : FTP Tx: "TYPE I"
2024/12/03 15:57:37 DEBUG : FTP Rx: "200 Type set to I."
2024/12/03 15:57:37 DEBUG : FTP Tx: "OPTS UTF8 ON"
2024/12/03 15:57:37 DEBUG : FTP Rx: "200 OPTS UTF8 command successful - UTF8 encoding now ON."
2024/12/03 15:57:37 DEBUG : fs cache: renaming cache item "myftp:" to be canonical "myftp{zV8cd}:"
2024/12/03 15:57:37 DEBUG : FTP Tx: "EPSV"
2024/12/03 15:57:37 DEBUG : FTP Rx: "229 Entering Extended Passive Mode (|||53034|)"
2024/12/03 15:57:37 DEBUG : ftp://ftp.myftp.pt:21: dial("tcp","**redacted**:53034")
2024/12/03 15:57:38 DEBUG : ftp://ftp.myftp.pt:21: > dial: conn=*fshttp.timeoutConn, err=<nil>
2024/12/03 15:57:38 DEBUG : FTP Tx: "LIST"
2024/12/03 15:57:38 DEBUG : FTP Rx: "125 Data connection already open; Transfer starting."
2024/12/03 15:57:38 DEBUG : FTP Rx: "226 Transfer complete."
2024/12/03 15:57:38 DEBUG : FTP Rx: "10-28-2024  12:51PM       <DIR>          folder1"
2024/12/03 15:57:38 DEBUG : FTP Rx: "12-03-2024  03:57PM       <DIR>          folder2"
2024/12/03 15:57:38 DEBUG : FTP Rx: "06-21-2021  02:34PM       <DIR>          folder3"
2024/12/03 15:57:38 DEBUG : FTP Rx: "12-03-2024  03:57PM       <DIR>          folder4"
2024/12/03 15:57:38 DEBUG : FTP Rx: "12-03-2024  03:57PM       <DIR>          folder5"
2024/12/03 15:57:38 DEBUG : FTP Rx: "12-12-2022  01:50PM       <DIR>          folder6"
2024/12/03 15:57:38 DEBUG : FTP Rx: "12-03-2024  03:57PM       <DIR>          folder7"
2024/12/03 15:57:38 DEBUG : FTP Rx: "12-03-2024  03:57PM       <DIR>          folder8"
2024/12/03 15:57:38 DEBUG : FTP Rx: "12-03-2024  03:57PM       <DIR>          folder9"
2024/12/03 15:57:38 DEBUG : FTP Rx: "12-03-2024  03:57PM       <DIR>          folder10"
2024/12/03 15:57:38 DEBUG : FTP Rx: "12-03-2024  03:57PM       <DIR>          folder11"
2024/12/03 15:57:38 DEBUG : FTP Rx: "12-03-2024  03:57PM       <DIR>          folder12"
2024/12/03 15:57:38 DEBUG : FTP Rx: "03-01-2024  12:33PM       <DIR>          folder13"
2024/12/03 15:57:38 DEBUG : FTP Rx: "09-12-2024  09:14AM       <DIR>          folder14"
2024/12/03 15:57:38 DEBUG : 4 go routines active
2024/12/03 15:57:38 DEBUG : ftp://ftp.myftp.pt:21: closing 1 unused connections
2024/12/03 15:57:38 DEBUG : FTP Tx: "QUIT"
```

I'm facing this issue on most "Microsoft FTP Service" I'm trying to connect to.
It looks like the ls format has changed from one version to another (can't tell you which version, these are public FTP servers)

The supported date format that works with rclone is:
`11-27-24  09:59AM       <DIR>          folder`
The one that doesn't is:
`03-01-2024  12:33PM       <DIR>          folder`

I have created a minimalistic FTP server to confirm my doubt. By sending back both date format. Here are the logs: [https://pastebin.com/SMCEqRs3](https://pastebin.com/SMCEqRs3)

I believe it comes from this line: [https://github.com/rclone/ftp/blob/dev/parse.go#L25](https://github.com/rclone/ftp/blob/dev/parse.go#L25)

I wish I could help you more but I don't know how to build the project, never worked in GO and can't say I'm an expert in FTP, so I don't want to break anything.


Discussion / hints:
Hi!

This issues seems familiar - I'm sure it has come up before... Here it is

https://forum.rclone.org/t/microsoft-ftps-rclone-lsd-remote-doesnt-list-files/42910/

It is worth reading through that thread as there are settings you can change and a fix for the upstream library.

I'm not sure if the fix mentioned every got submitted upstream - I can't find it.

I did find the code though

https://github.com/esperlu/ftp/commits/master/

@esperlu are you planning on submitting this to https://github.com/jlaffaye/ftp ? If you want I can rebase it and submit it for you.
Hi!

Thank you for replying so quickly!
I'll take a close look at your links
Hi @ncw
Thank you again for your help, I managed to update the upstream FTP library and build myself a version that works with the FTP server I'm using.
Your explanations on the forum were clear enough to build and seems also clear enough to update the library if I ever have to.
I hope this fix will be merged soon, it could definitely help other people.
Great, thanks for testing @NicolasCordier 

I'll submit those patches if I can

Fix patch:
diff --git a/go.mod b/go.mod
index 412f622f1a225..962aaea79e310 100644
--- a/go.mod
+++ b/go.mod
@@ -41,7 +41,7 @@ require (
 	github.com/henrybear327/Proton-API-Bridge v1.0.0
 	github.com/henrybear327/go-proton-api v1.0.0
 	github.com/jcmturner/gokrb5/v8 v8.4.4
-	github.com/jlaffaye/ftp v0.2.0
+	github.com/jlaffaye/ftp v0.2.1-0.20240918233326-1b970516f5d3
 	github.com/josephspurrier/goversioninfo v1.4.1
 	github.com/jzelinskie/whirlpool v0.0.0-20201016144138-0675e54bb004
 	github.com/klauspost/compress v1.17.11
diff --git a/go.sum b/go.sum
index 0ea2346066108..1b0f4578f4019 100644
--- a/go.sum
+++ b/go.sum
@@ -398,8 +398,8 @@ github.com/jcmturner/gokrb5/v8 v8.4.4/go.mod h1:1btQEpgT6k+unzCwX1KdWMEwPPkkgBtP
 github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZY=
 github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc=
 github.com/jlaffaye/ftp v0.0.0-20190624084859-c1312a7102bf/go.mod h1:lli8NYPQOFy3O++YmYbqVgOcQ1JPCwdOy+5zSjKJ9qY=
-github.com/jlaffaye/ftp v0.2.0 h1:lXNvW7cBu7R/68bknOX3MrRIIqZ61zELs1P2RAiA3lg=
-github.com/jlaffaye/ftp v0.2.0/go.mod h1:is2Ds5qkhceAPy2xD6RLI6hmp/qysSoymZ+Z2uTnspI=
+github.com/jlaffaye/ftp v0.2.1-0.20240918233326-1b970516f5d3 h1:ZxO6Qr2GOXPdcW80Mcn3nemvilMPvpWqxrNfK2ZnNNs=
+github.com/jlaffaye/ftp v0.2.1-0.20240918233326-1b970516f5d3/go.mod h1:dvLUr/8Fs9a2OBrEnCC5duphbkz/k/mSy5OkXg3PAgI=
 github.com/josephspurrier/goversioninfo v1.4.1 h1:5LvrkP+n0tg91J9yTkoVnt/QgNnrI1t4uSsWjIonrqY=
 github.com/josephspurrier/goversioninfo v1.4.1/go.mod h1:JWzv5rKQr+MmW+LvM412ToT/IkYDZjaclF2pKDss8IY=
 github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=


Test patch: