Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:14530 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79166 invoked by uid 1010); 2 Feb 2005 20:12:14 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 78749 invoked from network); 2 Feb 2005 20:12:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Feb 2005 20:12:06 -0000 X-Host-Fingerprint: 12.18.144.101 charon.simplot.com Linux 2.4/2.6 Received: from ([12.18.144.101:35330] helo=occ01mx006.simplot.com) by pb1.pair.com (ecelerity HEAD (r4105:4106)) with SMTP id E8/23-25397-10431024 for ; Wed, 02 Feb 2005 15:11:46 -0500 Received: from occ01mx003.na.simplot.com (occ01mx003.na.simplot.com [10.10.6.25]) by occ01mx006.simplot.com (JRSmailserver) with SMTP id 1D92ACE5EB for ; Wed, 2 Feb 2005 13:12:18 -0700 (MST) Received: from 10.10.6.3 by occ01mx003.na.simplot.com (InterScan E-Mail VirusWall NT); Wed, 02 Feb 2005 13:11:30 -0700 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPartTM-000-97bcc291-43c8-4b00-ad94-d63a72288ccf" Date: Wed, 2 Feb 2005 13:11:30 -0700 Message-ID: <5367F26C013DE8429873569307F6F4A3BC27AE@OCC01MX023.na.simplot.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PHP-DEV] [PATCH] Bug# 27633 - Wrong translation in ASCII mode Thread-Index: AcUJXre0hPgxUuAITQ67kk6u+jcBaQABAZUAAAAuSfA= To: Subject: RE: [PHP-DEV] [PATCH] Bug# 27633 - Wrong translation in ASCII mode From: Jesse.Binam@simplot.com ("Binam, Jesse") ------=_NextPartTM-000-97bcc291-43c8-4b00-ad94-d63a72288ccf Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C50963.625E2068" ------_=_NextPart_001_01C50963.625E2068 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable WTF?? Appearently the attachment is getting stripped off somewhere along the way... =20 Index: ext/ftp/ftp.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /repository/php-src/ext/ftp/ftp.c,v retrieving revision 1.106 diff -u -r1.106 ftp.c --- ext/ftp/ftp.c 5 Oct 2004 23:53:09 -0000 1.106 +++ ext/ftp/ftp.c 2 Feb 2005 19:09:28 -0000 @@ -846,16 +846,25 @@ * Everything Else \n */ #ifdef PHP_WIN32 - while ((s =3D strpbrk(ptr, "\r\n"))) { - if (*s =3D=3D '\n') { - php_stream_putc(outstream, '\r'); + while ((s =3D strpbrk(ptr, "\r\n")) && (s < e)) { + + /* for some reason some servers prefix a \r before a \n,=20 + * resulting in a \r\r\n in the buffer when + * the remote file already has windoze style line endings. + */ + + php_stream_write(outstream, ptr, (s - ptr)); + php_stream_putc(outstream, '\r'); + php_stream_putc(outstream, '\n'); + if (*s =3D=3D '\r' && *(s + 1) =3D=3D '\r' && *(s + 2) =3D=3D '\n') = { + s +=3D 3; } else if (*s =3D=3D '\r' && *(s + 1) =3D=3D '\n') { + s +=3D 2; + } else if (*s =3D=3D '\r') {=20 + s++; + } else if (*s =3D=3D '\n') { s++; - } - s++; - php_stream_write(outstream, ptr, (s - ptr)); - if (*(s - 1) =3D=3D '\r') { - php_stream_putc(outstream, '\n'); } ptr =3D s; } ________________________________ From: Binam, Jesse [mailto:Jesse.Binam@simplot.com]=20 Sent: Wednesday, February 02, 2005 1:04 PM To: internals@lists.php.net Subject: RE: [PHP-DEV] [PATCH] Bug# 27633 - Wrong translation in ASCII mode I guess the patch would be helpful ;) ________________________________ From: Binam, Jesse [mailto:Jesse.Binam@simplot.com]=20 Sent: Wednesday, February 02, 2005 12:34 PM To: internals@lists.php.net Subject: [PHP-DEV] [PATCH] Bug# 27633 - Wrong translation in ASCII mode Can somebody please review and either commit and/or give me some feedback. It is against HEAD as of about 30 minutes ago. =20 This is a data integrity issue so I would think it would be extremely high priority. This is a problem in both 4.3.10 and 5.0.3, this patch should apply nicely to both branches. =20 Jess ------_=_NextPart_001_01C50963.625E2068 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
WTF?? Appearently the attachment is getting = stripped off=20 somewhere along the way...
 
Index:=20 ext/ftp/ftp.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
= RCS=20 file: /repository/php-src/ext/ftp/ftp.c,v
retrieving revision = 1.106
diff=20 -u -r1.106 ftp.c
--- ext/ftp/ftp.c 5 = Oct 2004=20 23:53:09 -0000 1.106
+++ ext/ftp/ftp.c 2 Feb 2005 19:09:28=20 -0000
@@ -846,16 +846,25 @@
     * Everything = Else=20 \n
     */
 #ifdef=20 PHP_WIN32
-   while ((s =3D strpbrk(ptr, "\r\n")))=20 {
-    if (*s =3D=3D '\n')=20 {
-     php_stream_putc(outstream,=20 '\r');
+   while ((s =3D strpbrk(ptr, "\r\n")) = && (s=20 < e)) {
+
+    /* for some reason some = servers=20 prefix a \r before a \n,
+     * resulting in a = \r\r\n=20 in the buffer when
+     * the remote file = already has=20 windoze style line endings.
+    =20 */
+
+    php_stream_write(outstream, ptr, (s = -=20 ptr));
+    php_stream_putc(outstream,=20 '\r');
+    php_stream_putc(outstream,=20 '\n');
+    if (*s =3D=3D '\r' && *(s + = 1) =3D=3D '\r'=20 && *(s + 2) =3D=3D '\n') {
+     s = +=3D=20 3;
     } else if (*s =3D=3D '\r' && = *(s + 1) =3D=3D=20 '\n') {
+     s +=3D = 2;
+    }=20 else if (*s =3D=3D '\r') {=20
+     s++;
+    } = else if=20 (*s =3D=3D '\n')=20 {
      s++;
-    = ;}
-    s++;
-    php_strea= m_write(outstream,=20 ptr, (s - ptr));
-    if (*(s - 1) =3D=3D '\r')=20 {
-     php_stream_putc(outstream,=20 '\n');
     }
    &nbs= p;ptr =3D=20 s;
    }


From: Binam, Jesse=20 [mailto:Jesse.Binam@simplot.com]
Sent: Wednesday, February = 02, 2005=20 1:04 PM
To: internals@lists.php.net
Subject: RE: = [PHP-DEV]=20 [PATCH] Bug# 27633 - Wrong translation in ASCII = mode

I guess the patch would be helpful=20 ;)


From: Binam, Jesse=20 [mailto:Jesse.Binam@simplot.com]
Sent: Wednesday, February = 02, 2005=20 12:34 PM
To: internals@lists.php.net
Subject: = [PHP-DEV]=20 [PATCH] Bug# 27633 - Wrong translation in ASCII = mode

Can = somebody please=20 review and either commit and/or give me some feedback. It is against = HEAD as of=20 about 30 minutes ago.
 
This = is a data=20 integrity issue so I would think it would be extremely high=20 priority.
This = is=20 a problem in both 4.3.10 and 5.0.3, this patch should apply nicely = to both=20 branches.
 
Jess
------_=_NextPart_001_01C50963.625E2068-- ------=_NextPartTM-000-97bcc291-43c8-4b00-ad94-d63a72288ccf--