Subject: SFTP and cross-platform text file detection.

From: "Ouadah Farid" <[email-masked]>
Date: Mon, 30 May 2005 15:31:29 +0200

Hello,

I'm confronted to an interesting problem that might require some precisions in the "SSH file transfer protocol".

Many Windows or Unix modern applications can transparently operate text-files even if they are not in their native format (I.E: Unix texte file for a Windows application).
Stating about the ability for SFTP servers to do so might be intersting since different behaviours could lead to different results.
Since a proper local file format cannot always be guaranteed (I.E: for shared filesystems) a same operation could give very different results.

By example if we compare a text file transfer originating from two kinds of SFTP theorical servers (a "strict" one and a "relaxed" one) it could lead to very different results.
A strict application only recognize its own local newline format.
A relaxed application is capable of reading more than it's own file format (A windows or Unix application that can read both LF and CRLF as a newline).

A Unix text file transfered with a strict SFTP Windows server would be send unchanged (if we imagine that the client has no hint about the file format).
A Unix text file transfered with a relaxed SFTP Windows server would be send transcoded (LF -> CRLF with the default newline convention).

A Windows text transfered with a strict SFTP Unix server would be send transcoded (CRLF -> CRCRLF with the default newline convention).
A Windows text transfered with a relaxed SFTP Unix server would be send transcoded differently (CRLF -> CRLF with the default newline convention).

From the client side, the resulting file could be very different.

I have restricted the case to Windows and Unix but the problem concerns every kind of SFTP server and text file.

I think that either a relaxed text-file detection should be forbidden or there must be some way to avoid mistakes.

I hope I was clear enough.

What is your opinion ?

Farid