]> granicus.if.org Git - php/commitdiff
Final set of fixes for bug #27633.
authorIlia Alshanetsky <iliaa@php.net>
Thu, 10 Mar 2005 23:37:45 +0000 (23:37 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 10 Mar 2005 23:37:45 +0000 (23:37 +0000)
# Many thanks to Edin for helpind analyze and resolve this bug.

ext/ftp/ftp.c
ext/ftp/php_ftp.c

index 01bbf3905bd7347eafd1101e670fdf8b75cddb4b..8a229a17c62accbf999e9633b10ad933166e0c55 100644 (file)
@@ -846,25 +846,8 @@ 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")) && (s < e)) {
-                               php_stream_write(outstream, ptr, (s - ptr));
-                               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;
-                       }
+                       php_stream_write(outstream, ptr, (e - ptr));
+                       ptr = e;
 #else
                        while (e > ptr && (s = memchr(ptr, '\r', (e - ptr)))) {
                                php_stream_write(outstream, ptr, (s - ptr));
index c527696c6b2ca2d57a5bad9a4828717f889d7ecb..4fa30ef73865532031398af4093e61c8e8f304e0 100644 (file)
@@ -679,6 +679,10 @@ PHP_FUNCTION(ftp_get)
                resumepos = 0;
        }
 
+#ifdef PHP_WIN32
+       mode = FTPTYPE_IMAGE;
+#endif
+
        if (ftp->autoseek && resumepos) {
                outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt+" : "rb+", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);
                if (outstream == NULL) {
@@ -737,7 +741,9 @@ PHP_FUNCTION(ftp_nb_get)
        if (!ftp->autoseek && resumepos == PHP_FTP_AUTORESUME) {
                resumepos = 0;
        }
-
+#ifdef PHP_WIN32
+       mode = FTPTYPE_IMAGE;
+#endif
        if (ftp->autoseek && resumepos) {
                outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt+" : "rb+", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);
                if (outstream == NULL) {