dani-garcia / rust_async_ftp

Fork of https://crates.io/crates/ftp with tokio async support
Apache License 2.0
21 stars 14 forks source link

Split lines according to both dos and unix conventions #2

Closed dodomorandi closed 4 years ago

dodomorandi commented 4 years ago

The current implementation could be simpler, but it would need the stream feature from tokio. In this way there is no compile-time overhead and the code should be understandable.

Closes #3

dani-garcia commented 4 years ago

I'm pretty sure the FTP RFC only specifies \r\n as a valid line ending, but I can't look it up, do you know of any server that does otherwise? That said, it shouldn't be a problem for the client to be a bit more lenient in what it accepts.

dodomorandi commented 4 years ago

Unfortunately this bit me as well: according to RFC 959 about the LIST command:

The data transfer is over the data connection in type ASCII or type EBCDIC. (The user must ensure that the TYPE is appropriately ASCII or EBCDIC). Since the information on a file may vary widely from system to system, this information may be hard to use automatically in a program, but may be quite useful to a human user.

This means that LIST could theoretically be any sort of human-friendly text, without any sort of format (or newline) specification. I did not like the FTP protocol before digging into these details, things are not getting any better :roll_eyes:

do you know of any server that does otherwise?

Yes, ftp.sda.it uses unix newlines (and it does not use any security protocol, but that's another story). You need to be authenticated, therefore you need to trust me on this, sorry :man_shrugging:.

dani-garcia commented 4 years ago

Oh I know the pain of underspecified specs and system dependend behaviour 🤣

I was hoping that seeing as FTP is a pretty simple protocol, the spec would be better defined but apparently not.