Hi all,
I try to access files on an SFTP server (using Jsch) which use for their names 
an encoding different from UTF-8 (in my case, ISO-8859-1). I have found an old 
discussion about that topic 
(https://sourceforge.net/p/jsch/mailman/message/26647296/) and a corresponding 
entry in the changelog for version 0.1.45 ("bugfix: sftp protocol version 3, 4 
and 5 should allow only UTF-8 encoding"). However, I think that their might be 
some misunderstanding about the SFTP version numbers which leads to a still 
incorrect behavior of Jsch.
Looking at the specs (e.g. 
https://tools.ietf.org/html/draft-ietf-secsh-filexfer-00), I see that there are 
14 versions of the specs. However, these do *not* correspond to the SFTP 
protocol version in a one-to-one manner. The SFTP protocol version for each of 
the spec versions is given in the section "Protocol Initialization". Looking at 
this section, we find that spec versions 0 to 2 describe protocol version 3, 
spec versions 3 and 4 describe protocol version 4, spec version 5 describe 
protocol version 5 and spec versions 6 to 13 describe protocol version 6. (This 
information can also be found at 
https://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol#History_and_development.)
In the original protocol version 3, the filename encoding is undefined. In 
protocol versions 4 and 5, the filename encoding must be UTF-8, and in protocol 
version 6, the filename encoding can be negotiated. This has also been 
discussed in the old mailing list thread, but the versions mentioned in that 
thread were the spec versions, and not the protocol versions. So the current 
implementation ...

    if(3 <= sversion && sversion <= 5 &&
       !encoding.equals(UTF8)){
      throw new SftpException(SSH_FX_FAILURE,
                              "The encoding can not be changed for this sftp 
server.");
    }

... is not correct in my opinion and should be changed to ...

    if(4 <= sversion && sversion <= 5 &&
       !encoding.equals(UTF8)){
      throw new SftpException(SSH_FX_FAILURE,
                              "The encoding can not be changed for this sftp 
server.");
    }

... because only protocol versions 4 and 5 hardcoded the encoding to be UTF-8.

Regards,
Christian

PS: This mail doesn't seem to have come through the first time, so I resend it. 
Please excuse if it actually is a duplicate now.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users

Reply via email to