From 27ff4efb166979a1251e0a8b2faa801e55110ff9 Mon Sep 17 00:00:00 2001 From: pdontthink Date: Fri, 3 Jun 2005 19:56:36 +0000 Subject: [PATCH] Fix that addresses inconsistency in PHP's chunk_split; was breaking attachments. Thanks to Roalt Zijlstra git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@9495 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- ChangeLog | 3 +++ class/deliver/Deliver.class.php | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3f55274a..e40d975b 100644 --- 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 passwall.com. + - Fixed broken attachments caused by inconsistency of PHP chunk_split(). + Thanks to Roalt Zijlstra. + Version 1.5.0 - 2 February 2004 ------------------------------- diff --git a/class/deliver/Deliver.class.php b/class/deliver/Deliver.class.php index bd952764..4d526a78 100644 --- a/class/deliver/Deliver.class.php +++ b/class/deliver/Deliver.class.php @@ -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 +?> -- 2.25.1