From: Michael M Slusarz Date: Wed, 1 Jul 2009 05:54:40 +0000 (-0600) Subject: More cleanups/fixes for new stream code. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=2b81c0fbec5bd79c0f2f9a8dd2a3083c552ed1fb;p=horde.git More cleanups/fixes for new stream code. --- diff --git a/imp/compose.php b/imp/compose.php index 238652b48..c96de2778 100644 --- a/imp/compose.php +++ b/imp/compose.php @@ -552,8 +552,8 @@ case 'selectlist_process': $data = $registry->call('files/returnFromSelectlist', array($select_id, $i++)); if ($data && !is_a($data, 'PEAR_Error')) { $part = new Horde_Mime_Part(); - $part->setContents($data); $part->setName(reset($val)); + $part->setContents($data); try { $imp_compose->addMIMEPartAttachment($part); } catch (IMP_Compose_Exception $e) { diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index 425a59557..d0fb5bffe 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -585,7 +585,7 @@ class IMP_Compose $replace_part = new Horde_Mime_Part(); $replace_part->setType('text/plain'); $replace_part->setCharset($charset); - $replace_part->setContents('[' . _("Attachment stripped: Original attachment type") . ': "' . $oldPart->getType() . '", ' . _("name") . ': "' . $oldPart->getName(true) . '"]', '8bit'); + $replace_part->setContents('[' . _("Attachment stripped: Original attachment type") . ': "' . $oldPart->getType() . '", ' . _("name") . ': "' . $oldPart->getName(true) . '"]'); $mime_message->alterPart($i, $replace_part); } } @@ -2058,7 +2058,7 @@ class IMP_Compose * fails (?) */ $part = new Horde_Mime_Part(); $part->setType($response->getHeader('content-type')); - $part->setContents($response->getBody(), '8bit'); + $part->setContents($response->getBody()); $part->setDisposition('attachment'); $img_data[$url] = '"cid:' . $part->setContentID() . '"'; $img_parts[] = $part; @@ -2157,14 +2157,14 @@ class IMP_Compose $link_part->setType('text/plain'); $link_part->setCharset($charset); $link_part->setDisposition('inline'); - $link_part->setContents($trailer, '8bit'); + $link_part->setContents($trailer); $link_part->setDescription(_("Attachment Information")); $mixed_part->addPart($link_part); return $mixed_part; } - $part->appendContents("\n-----\n" . $trailer, '8bit'); + $part->appendContents("\n-----\n" . $trailer); return $part; } diff --git a/imp/lib/Message.php b/imp/lib/Message.php index e816d0b5e..488581002 100644 --- a/imp/lib/Message.php +++ b/imp/lib/Message.php @@ -516,7 +516,7 @@ class IMP_Message /* We need to make sure all text is in the correct charset. */ $newPart->setCharset(NLS::getCharset()); - $newPart->setContents(sprintf(_("[Attachment stripped: Original attachment type: %s, name: %s]"), $oldPart->getType(), $oldPart->getName(true)), '8bit'); + $newPart->setContents(sprintf(_("[Attachment stripped: Original attachment type: %s, name: %s]"), $oldPart->getType(), $oldPart->getName(true))); $message->alterPart($partid, $newPart); } diff --git a/imp/lib/Spam.php b/imp/lib/Spam.php index c9e628396..1c5262b1f 100644 --- a/imp/lib/Spam.php +++ b/imp/lib/Spam.php @@ -99,7 +99,7 @@ class IMP_Spam if ($to) { if (!isset($raw_msg)) { - $raw_msg = $imp_contents->fullMessageText(); + $raw_msg = $imp_contents->fullMessageText(true); } if (!isset($imp_compose)) { diff --git a/imp/view.php b/imp/view.php index a7950ffb7..9f2db616d 100644 --- a/imp/view.php +++ b/imp/view.php @@ -39,8 +39,8 @@ function _sanitizeName($name) function _fullMessageTextLength($ob) { - fseek($ob[1], 0, SEEK_END); - $len = strlen($ob[0]) + ftell($ob[1]); + $stat = fstat($ob[1]); + $len = strlen($ob[0]) + $stat['size']); rewind($ob[1]); return $len; } @@ -153,6 +153,7 @@ case 'download_render': $browser->downloadHeaders($name, $type, false, strlen($body)); if (is_resource($body)) { + rewind($body); fpassthru($body); } else { echo $body; @@ -173,6 +174,7 @@ case 'view_source': $msg = $contents->fullMessageText(array('stream' => true)); $browser->downloadHeaders('Message Source', 'text/plain', true, _fullMessageTextLength($msg)); echo $msg[0]; + rewind($msg[1]); fpassthru($msg[1]); exit; @@ -195,6 +197,7 @@ case 'save_message': $msg = $contents->fullMessageText(array('stream' => true)); $browser->downloadHeaders($name . '.eml', 'message/rfc822', false, strlen($hdr) + _fullMessageTextLength($msg)); echo $hdr . $msg[0]; + rewind($msg[1]); fpassthru($msg[1]); exit; }