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 3f55274..e40d975 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 bd95276..4d526a7 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
+?>