From 252737e154cdcdfed28cd6c5710cdb0d7a00dd2e Mon Sep 17 00:00:00 2001 From: stekkel Date: Thu, 5 Sep 2002 12:48:44 +0000 Subject: [PATCH] remove unnessecarry \r\n git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@3565 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- class/deliver/Deliver.class.php | 36 +++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/class/deliver/Deliver.class.php b/class/deliver/Deliver.class.php index 403506c6..2dfb2c71 100644 --- a/class/deliver/Deliver.class.php +++ b/class/deliver/Deliver.class.php @@ -56,7 +56,7 @@ class Deliver { if ($i == $entCount-1) $last = true; } if ($boundary && $last) { - $s = "\r\n--".$boundary."--\r\n\r\n"; + $s = "--".$boundary."--\r\n\r\n"; $length_raw += strlen($s); if ($stream) { $this->preWriteToStream($s); @@ -71,6 +71,8 @@ class Deliver { } else { $type0 = $message->rfc822_header->content_type->type0; } + + $body_part_trailing = $last = ''; switch ($type0) { case 'text': case 'message': @@ -81,15 +83,17 @@ class Deliver { $this->preWriteToStream($body_part); $this->writeToStream($stream, $body_part); } + $last = $body_part; } elseif ($message->att_local_name) { $filename = $message->att_local_name; $file = fopen ($filename, 'rb'); - while ($tmp = fgets($file, 4096)) { - $length += $this->clean_crlf($tmp); + while ($body_part = fgets($file, 4096)) { + $length += $this->clean_crlf($body_part); if ($stream) { - $this->preWriteToStream($tmp); - $this->writeToStream($stream, $tmp); + $this->preWriteToStream($body_part); + $this->writeToStream($stream, $body_part); } + $last = $body_part; } fclose($file); } @@ -104,22 +108,28 @@ class Deliver { } elseif ($message->att_local_name) { $filename = $message->att_local_name; $file = fopen ($filename, 'rb'); + $encoded = ''; while ($tmp = fread($file, 570)) { - $encoded = chunk_split(base64_encode($tmp)); - + $body_part = chunk_split(base64_encode($tmp)); + $length += $this->clean_crlf($body_part); if ($stream) { - $this->writeToStream($stream, $encoded); + $this->writeToStream($stream, $body_part); } } fclose($file); } break; } - $body_part_trailing = "\r\n"; - $length += strlen($body_part_trailing); - if ($stream) { - $this->preWriteToStream($body_part_trailing); - $this->writeToStream($stream, $body_part_trailing); + $body_part_trailing = ''; + if ($last && substr($last,-1) != "\n") { + $body_part_trailing = "\r\n"; + } + if ($body_part_trailing) { + $length += strlen($body_part_trailing); + if ($stream) { + $this->preWriteToStream($body_part_trailing); + $this->writeToStream($stream, $body_part_trailing); + } } } -- 2.25.1