summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2005-02-17 15:37:24 +0000
committerIlia Alshanetsky <iliaa@php.net>2005-02-17 15:37:24 +0000
commitf2eb0acfcf3f484cd1650cfc3861f2519102a751 (patch)
tree06338f7202f0870ea2758566833f118fdf7c5552 /ext
parent4f4cb653003c1f2c952cfb34cbe321fb099cbc31 (diff)
downloadphp-git-f2eb0acfcf3f484cd1650cfc3861f2519102a751.tar.gz
Fixed bug #27633 (Double \r\r problem on ftp_get in ASCII mode on Win32).
Diffstat (limited to 'ext')
-rw-r--r--ext/ftp/ftp.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c
index 345cbc5731..51cccab02b 100644
--- a/ext/ftp/ftp.c
+++ b/ext/ftp/ftp.c
@@ -846,16 +846,22 @@ ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type,
* Everything Else \n
*/
#ifdef PHP_WIN32
- while ((s = strpbrk(ptr, "\r\n"))) {
- if (*s == '\n') {
- php_stream_putc(outstream, '\r');
- } else if (*s == '\r' && *(s + 1) == '\n') {
- s++;
- }
- s++;
+ while ((s = strpbrk(ptr, "\r\n")) && (s < e)) {
php_stream_write(outstream, ptr, (s - ptr));
- if (*(s - 1) == '\r') {
- php_stream_putc(outstream, '\n');
+ php_stream_write(outstream, "\r\n", sizeof("\r\n")-1);
+
+ if (*s == '\r') {
+ *s++;
+ }
+ /* for some reason some servers prefix a \r before a \n,
+ * resulting in a \r\r\n in the buffer when
+ * the remote file already has windoze style line endings.
+ */
+ if (*s == '\r') {
+ *s++;
+ }
+ if (*s == '\n') {
+ *s++;
}
ptr = s;
}