summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsvncommit <devs@roundcube.net>2006-09-23 23:36:34 +0000
committersvncommit <devs@roundcube.net>2006-09-23 23:36:34 +0000
commited65922364bafd97248af2bc7df4fdb61b906574 (patch)
treec6af30b89b72f457ba6b7129f2aadf38e39476b4
parentc8c1a30ceb84086926bcde4dc1495d0e646366de (diff)
prevent multiple copies of an emoticon image from being attached to an outgoing message
-rw-r--r--program/steps/mail/sendmail.inc28
1 files changed, 20 insertions, 8 deletions
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index b4a6b7c20..3e368ee90 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -89,22 +89,34 @@ function rcmail_attach_emoticons(&$mime_message)
$searchstr = 'program/js/tiny_mce/plugins/emotions/images/';
+ // keep track of added images, so they're only added once
+ $included_images = array();
+
// find emoticon image tags
while ($pos = strpos($body, $searchstr, $last_img_pos))
{
$pos2 = strpos($body, '"', $pos);
$body_pre = substr($body, 0, $pos);
- $image_name = substr($body, $pos + strlen($searchstr), $pos2 - ($pos + strlen($searchstr)));
- $body_post = substr($body, $pos2);
+ $image_name = substr($body,
+ $pos + strlen($searchstr),
+ $pos2 - ($pos + strlen($searchstr)));
+
+write_log('emoticon', "looking for $image_name in array:" . print_r($included_images, true));
- // add the image to the MIME message
- $img_file = $INSTALL_PATH . '/' . $searchstr . $image_name;
- if(! $mime_message->addHTMLImage($img_file, 'image/gif', '', true, '_' . $image_name))
+ if (! in_array($image_name, $included_images))
{
- show_message("emoticonerror", 'error');
- }
+ $body_post = substr($body, $pos2);
- $body = $body_pre . 'cid:_' . $image_name . $body_post;
+ // add the image to the MIME message
+ $img_file = $INSTALL_PATH . '/' . $searchstr . $image_name;
+ if(! $mime_message->addHTMLImage($img_file, 'image/gif', '', true, '_' . $image_name))
+ {
+ show_message("emoticonerror", 'error');
+ }
+
+ $body = $body_pre . 'cid:_' . $image_name . $body_post;
+ array_push($included_images, $image_name);
+ }
$last_img_pos = $pos2;
}