From a40f3581deb1cac7f7d764743f320a0a2b1caafa Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Fri, 14 Nov 2008 16:23:08 -0700 Subject: [PATCH] Allow contents to be set in parseMessage(). --- framework/Mime/lib/Horde/Mime/Message.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/framework/Mime/lib/Horde/Mime/Message.php b/framework/Mime/lib/Horde/Mime/Message.php index 2f9539681..7f1de72b2 100644 --- a/framework/Mime/lib/Horde/Mime/Message.php +++ b/framework/Mime/lib/Horde/Mime/Message.php @@ -136,6 +136,7 @@ class Horde_Mime_Message extends Horde_Mime_Part * 'subtype' - (string) The MIME subtype * * The array MAY contain the following information: + * 'contents' - (string) The contents of the part. * 'disposition' - (string) The disposition type of the part (e.g. * 'attachment', 'inline'). * 'dparameters' - (array) Attribute/value pairs from the part's @@ -209,6 +210,11 @@ class Horde_Mime_Message extends Horde_Mime_Part $ob->setTransferEncoding($data['encoding']); } + if (isset($data['contents'])) { + $ob->setContents($data['contents'], $ob->getTransferEncoding()); + $ob->transferDecodeContents(); + } + if (isset($data['disposition'])) { $ob->setDisposition($data['disposition']); if (!empty($data['dparameters'])) { @@ -363,13 +369,15 @@ class Horde_Mime_Message extends Horde_Mime_Part } /* Get file size (if 'body' text is set). */ - if (isset($ob->body) && - ($part['type'] != 'message') && - ($part['subtype'] != 'rfc822')) { - /* Mail_mimeDecode puts an extra linebreak at the end of body - * text. */ - $size = strlen(str_replace(array("\r\n", "\n"), array("\n", "\r\n"), $ob->body)) - 2; - $part['size'] = ($size < 0) ? 0 : $size; + if (isset($ob->body)) { + $part['contents'] = $ob->body; + if (($part['type'] != 'message') && + ($part['subtype'] != 'rfc822')) { + /* Mail_mimeDecode puts an extra linebreak at the end of body + * text. */ + $size = strlen(str_replace(array("\r\n", "\n"), array("\n", "\r\n"), $ob->body)) - 2; + $part['size'] = ($size < 0) ? 0 : $size; + } } /* Process parts also. */ -- 2.11.0