Aleksander Machniak
2015-02-18 d67071f228ea39e22d5109f800b68efaf7146d4b
Fix saving/sending emoticon images when assets_dir is set (Kolab #4608)
1 files modified
14 ■■■■■ changed files
program/steps/mail/sendmail.inc 14 ●●●●● patch | view | raw | blame | history
program/steps/mail/sendmail.inc
@@ -765,8 +765,10 @@
    // remove any null-byte characters before parsing
    $body = preg_replace('/\x00/', '', $body);
    $searchstr = 'program/js/tinymce/plugins/emoticons/img/';
    $offset = 0;
    $searchstr  = 'program/js/tinymce/plugins/emoticons/img/';
    $assets_dir = $RCMAIL->config->get('assets_dir');
    $path       = ($assets_dir ?: INSTALL_PATH) . '/' . $searchstr;
    $offset     = 0;
    // keep track of added images, so they're only added once
    $included_images = array();
@@ -779,12 +781,14 @@
                // sanitize image name so resulting attachment doesn't leave images dir
                $image_name = preg_replace('/[^a-zA-Z0-9_\.\-]/i', '', $image_name);
                $img_file   = INSTALL_PATH . '/' . $searchstr . $image_name;
                $img_file   = $path . $image_name;
                if (! in_array($image_name, $included_images)) {
                if (!in_array($image_name, $included_images)) {
                    // add the image to the MIME message
                    if (!$mime_message->addHTMLImage($img_file, 'image/gif', '', true, $image_name)) {
                    $res = $mime_message->addHTMLImage($img_file, 'image/gif', '', true, $image_name);
                    if (PEAR::isError($res)) {
                        $RCMAIL->output->show_message("emoticonerror", 'error');
                        continue;
                    }
                    array_push($included_images, $image_name);