WInSCP Not Handle CR/LF Correctly in Ascii Mode

Advertisement

billy2393
Joined:
Posts:
6
Location:
HK

WInSCP Not Handle CR/LF Correctly in Ascii Mode

When execute a script to get a text file from Windows server in Ascii mode. Some line ending x'0D0A' (cr/lf) are incorrectly converted to x'0D0D0A' (add 1 byte). I found that this happen when the x'0D0A' is located at offset 4096-4097, 8192-8193, etc. I check the profile for this server using gui. The end-of-line char in Environment is set to LF (default). I then change it to CR/LF and the problem is fixed. Of cause, change it to Binary mode also works. I just wonder if this is a bug in WinSCP because it handle CR/LF correctly execpt those fall on 4096 boundary only. It seems that the x'0D0A' are seperately handled by two process: (1) x'0D' remains unchanged and (2) x'0A' is converted to x'0D0A'.
Version: 5.1.3

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,431
Location:
Prague, Czechia

Re: WInSCP Not Handle CR/LF Correctly in Ascii Mode

What protocol are you using? Can you please email me a sample file? (compressed to avoid it being converted by the email clients).

Reply with quote

billy2393
Joined:
Posts:
6
Location:
HK

Re: WInSCP Not Handle CR/LF Correctly in Ascii Mode

martin wrote:

What protocol are you using? Can you please email me a sample file? (compressed to avoid it being converted by the email clients).
1. Protocol being used is SFTP
2. Attached is the testing files
3. Testing approach
- data in client is 4097 bytes. The last CR/LF falls on 4096 bondary.
- put to server using binary mode. The size at server should be 4096.
- then get it using ascii mode to data2.
- Server is Windows. Suppose size of data should also be 4096.
- data2 is 4098 bytes. One additional x'0D' in last line after char "A"
4. Content of cmdfile:
option batch on
option confirm off
option batch abort
open sftp://<user>:<password>@<remote_host>
binary
put "TEST_4097_DATA.txt" "/ITDSFTP/TEST_4097_DATA.txt"
ascii
get "/ITDSFTP/TEST_4097_DATA.txt" "TEST_4097_DATA2.txt"
Close
Exit
Description: testing files

Reply with quote

billy2393
Joined:
Posts:
6
Location:
HK

Re: WInSCP Not Handle CR/LF Correctly in Ascii Mode

Sorry for the typo.
3. Testing approach
- data in client is 4097 bytes. It has 16 lines and the last CR/LF falls on 4096-4097.
- put to Windows SFTP Server (installed Cygwin) using binary mode.
- the size at server is 4097.
- then get it using ascii mode to data2.
- data2 is 4098 bytes. One additional x'0D' in last line after char "A"

Reply with quote

Advertisement

billy2393
Joined:
Posts:
6
Location:
HK

Re: WInSCP Not Handle CR/LF Correctly in Ascii Mode

Sorry for the late reply. Just back from holidays.
The bug fix version works. I tested files in different size with this issue. They failed in old version and okay in new version. Thanks for the support.
Size
====
4097
8193
12289
16385
20481
24577

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,431
Location:
Prague, Czechia

Re: WInSCP Not Handle CR/LF Correctly in Ascii Mode

Thanks for your feedback.

billy2393 wrote:

It seems that this bug #1059 is same as bug #845, which was fixed in 5.0.7. Why the same bug happen again?
The 5.0.7 fix was not generic enough to cover all possibilities.

Reply with quote

Advertisement

You can post new topics in this forum