Fix that addresses inconsistency in PHP's chunk_split; was breaking attachments....
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 3 Jun 2005 19:56:36 +0000 (19:56 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 3 Jun 2005 19:56:36 +0000 (19:56 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@9495 7612ce4b-ef26-0410-bec9-ea0150e637f0

ChangeLog
class/deliver/Deliver.class.php

index 3f55274a59660caf8dc0f62ba2aef2007651dc2b..e40d975b6ff9b0bc1c0b2d874680dc984247e7fd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -360,6 +360,9 @@ Version 1.5.1 -- CVS
   - Move documentation for SquirrelMail developers to doc/Development.
   - Added id attribute support to form functions. It can be used for Section 
     508 or WAI fixes. Original idea and patch by dugan <at> passwall.com.
+  - Fixed broken attachments caused by inconsistency of PHP chunk_split().
+    Thanks to Roalt Zijlstra.
+
 
 Version 1.5.0 - 2 February 2004
 -------------------------------
index bd952764f70e6f2c71a1e42f40451fd679064d20..4d526a78e32d33ff2818bce74bbcba18673c0af8 100644 (file)
@@ -179,7 +179,12 @@ class Deliver {
                 $filename = $message->att_local_name;
                 $file = fopen ($filename, 'rb');
                 while ($tmp = fread($file, 570)) {
-                   $body_part = chunk_split(base64_encode($tmp));
+                    $body_part = chunk_split(base64_encode($tmp));
+                    // Up to 4.3.10 chunk_split always appends a newline,
+                    // while in 4.3.11 it doesn't if the string to split
+                    // is shorter than the chunk length.
+                    if( substr($body_part, -1 , 1 ) != "\n" )
+                        $body_part .= "\n";
                     $length += $this->clean_crlf($body_part);
                     if ($stream) {
                         $this->writeToStream($stream, $body_part);
@@ -784,4 +789,4 @@ class Deliver {
         return $ret;
     }
 }
-?>
\ No newline at end of file
+?>