From: Sara Golemon Date: Mon, 8 Sep 2003 22:40:12 +0000 (+0000) Subject: MFB(r-1.74.2.13) Bug #25314 ASCII mode transfers behaving like binary when initiated... X-Git-Tag: RELEASE_0_7~165 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4936234fd8af2f413b0ade2bec74f1fd6a2a1789;p=php MFB(r-1.74.2.13) Bug #25314 ASCII mode transfers behaving like binary when initiated from windows. --- diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c index 902b0565e4..0d0d7e0ae9 100644 --- a/ext/ftp/php_ftp.c +++ b/ext/ftp/php_ftp.c @@ -649,9 +649,9 @@ PHP_FUNCTION(ftp_get) } if (ftp->autoseek && resumepos) { - outstream = php_stream_open_wrapper(local, "rb+", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); + outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt+" : "rb+", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); if (outstream == NULL) { - outstream = php_stream_open_wrapper(local, "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); + outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); } if (outstream != NULL) { /* if autoresume is wanted seek to end */ @@ -663,7 +663,7 @@ PHP_FUNCTION(ftp_get) } } } else { - outstream = php_stream_open_wrapper(local, "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); + outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); } if (outstream == NULL) { @@ -707,9 +707,9 @@ PHP_FUNCTION(ftp_nb_get) } if (ftp->autoseek && resumepos) { - outstream = php_stream_open_wrapper(local, "rb+", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); + outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt+" : "rb+", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); if (outstream == NULL) { - outstream = php_stream_open_wrapper(local, "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); + outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); } if (outstream != NULL) { /* if autoresume is wanted seek to end */ @@ -721,7 +721,7 @@ PHP_FUNCTION(ftp_nb_get) } } } else { - outstream = php_stream_open_wrapper(local, "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); + outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); } if (outstream == NULL) { @@ -902,7 +902,7 @@ PHP_FUNCTION(ftp_put) ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf); XTYPE(xtype, mode); - if (!(instream = php_stream_open_wrapper(local, "rb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL))) { + if (!(instream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt" : "rb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL))) { RETURN_FALSE; } @@ -955,7 +955,7 @@ PHP_FUNCTION(ftp_nb_put) ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf); XTYPE(xtype, mode); - if (!(instream = php_stream_open_wrapper(local, "rb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL))) { + if (!(instream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt" : "rb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL))) { RETURN_FALSE; }