Topic "WInSCP Not Handle CR/LF Correctly in Ascii Mode"

Author Message
billy2393
[View user's profile]

Joined: 2013-09-06
Posts: 6
Location: HK
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
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
What protocol are you using? Can you please email me a sample file? (compressed to avoid it being converted by the email clients).
_________________
Martin Prikryl
billy2393
[View user's profile]

Joined: 2013-09-06
Posts: 6
Location: HK
prikryl 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
TEST_4097.zip (798 Bytes) [Download]

Description: testing files

billy2393
[View user's profile]

Joined: 2013-09-06
Posts: 6
Location: HK
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"
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
Thanks.

This bug has been added to the tracker:
https://winscp.net/tracker/show_bug.cgi?id=1059

I'm sending you a dev version for testing.
billy2393
[View user's profile]

Joined: 2013-09-06
Posts: 6
Location: HK
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
billy2393
[View user's profile]

Joined: 2013-09-06
Posts: 6
Location: HK
It seems that this bug #1059 is same as bug #845, which was fixed in 5.0.7. Why the same bug happen again?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
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.
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License