PHP :: Bug #25314 :: ASCII mode doesn't work
| Bug #25314 | ASCII mode doesn't work | ||||
|---|---|---|---|---|---|
| Submitted: | 2003-08-29 13:23 UTC | Modified: | 2004-01-06 00:32 UTC | ||
| From: | phpbugs at brianmertens dot com | Assigned: | |||
| Status: | Closed | Package: | FTP related | ||
| PHP Version: | 4.3.3 | OS: | Windows | ||
| Private report: | No | CVE-ID: | None | ||
[2003-08-29 13:23 UTC] phpbugs at brianmertens dot com
Description: ------------ This seems to be the same problem as 19036 (Closed) and 18162 (No Feedback). Since neither is still open, I am filing a new report. I will provide any feedback required. I can test snaps if they are compiled for Windows. Simply put, if I connect to a Unix (AIX 4.3) server and use ftp_get() to fetch a text file to a Windows machine with the FTP_ASCII option, the newlines are NOT converted to CR/LF pairs. ftp_get( $conn, "file.txt", "file.txt", FTP_ASCII ); I have reproduced this with 4.2.x, 4.3.2 & 4.3.3. (Note that ftp_systype() returns "UNKNOWN".) Reproduce code: --------------- $conn = ftp_connect( "server" ); ftp_login( $conn, "username", "password" ); ftp_get( $conn, "file.txt", "file.txt", FTP_ASCII ); Expected result: ---------------- Lines terminated with CR/LF pairs (x0D x0A). Actual result: -------------- Lines terminated with single x0A chars.
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2003-09-07 19:57 UTC] sniper@php.net
This works as workaround: <?php $conn = ftp_connect( "server" ); ftp_login( $conn, "user", "pass" ); $fp = fopen('localfile.txt', 'wt'); ftp_fget( $conn, $fp, 'remotefile.txt", FTP_BINARY ); ?>[2003-09-08 18:43 UTC] pollita@php.net
[2004-01-05 16:09 UTC] kshadkhast at canwest dot com
I think this problem has not fixed yet. I am using php4.3.4 and it got worth replacing \n to \r. this code must be put in ftp_get function to fix this problem: lastch = 0; while ((rcvd = my_recv(ftp, data->fd, data->buf, FTP_BUFSIZE))) { if (type == FTPTYPE_ASCII) { for (ptr = data->buf; rcvd; rcvd--, ptr++) { if ( *ptr == '\n') php_stream_putc(outstream, '\r'); if (lastch == '\r' && *ptr != '\n') php_stream_write(outstream, '\r\n', 2); if (*ptr != '\r') php_stream_putc(outstream, *ptr); lastch = *ptr; } } } if (type == FTPTYPE_ASCII && lastch == '\r') php_stream_write(outstream, '\r\n', 2);[2004-01-06 00:32 UTC] pollita@php.net