diff options
Diffstat (limited to 'program/steps/mail')
-rw-r--r-- | program/steps/mail/compose.inc | 55 | ||||
-rw-r--r-- | program/steps/mail/func.inc | 2 | ||||
-rw-r--r-- | program/steps/mail/get.inc | 24 | ||||
-rw-r--r-- | program/steps/mail/sendmail.inc | 35 |
4 files changed, 75 insertions, 41 deletions
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index 92296e525..db4efc7ce 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -53,13 +53,14 @@ if (!is_array($COMPOSE)) { } $COMPOSE_ID = uniqid(mt_rand()); + $params = rcube_utils::request2param(rcube_utils::INPUT_GET, 'task|action', true); + $_SESSION['compose_data_'.$COMPOSE_ID] = array( 'id' => $COMPOSE_ID, - 'param' => rcube_utils::request2param(rcube_utils::INPUT_GET, 'task|action', true), - 'mailbox' => $RCMAIL->storage->get_folder(), + 'param' => $params, + 'mailbox' => $params['mbox'] ?: $RCMAIL->storage->get_folder(), ); $COMPOSE =& $_SESSION['compose_data_'.$COMPOSE_ID]; - rcmail_process_compose_params($COMPOSE); // check if folder for saving sent messages exists and is subscribed (#1486802) @@ -322,13 +323,18 @@ foreach ($parts as $header) { $fvalue = $mailfollowup; else if ($mailreplyto) $fvalue = $mailreplyto; - else if (!empty($MESSAGE->headers->replyto)) - $fvalue = $MESSAGE->headers->replyto; + else if (!empty($MESSAGE->headers->replyto)) { + $fvalue = $MESSAGE->headers->replyto; + $replyto = true; + } else if (!empty($MESSAGE->headers->from)) $fvalue = $MESSAGE->headers->from; // Reply to message sent by yourself (#1487074, #1489230) - if (!empty($ident) && in_array($ident['ident'], array($fvalue, $MESSAGE->headers->from))) { + // Reply-To address need to be unset (#1490233) + if (!empty($ident) && empty($replyto) + && in_array($ident['ident'], array($fvalue, $MESSAGE->headers->from)) + ) { $fvalue = $MESSAGE->headers->to; } } @@ -419,7 +425,8 @@ $OUTPUT->add_handlers(array( 'filedroparea' => 'compose_file_drop_area', 'priorityselector' => 'rcmail_priority_selector', 'editorselector' => 'rcmail_editor_selector', - 'receiptcheckbox' => 'rcmail_receipt_checkbox', + 'receiptcheckbox' => 'rcmail_mdn_checkbox', // deprecated + 'mdncheckbox' => 'rcmail_mdn_checkbox', 'dsncheckbox' => 'rcmail_dsn_checkbox', 'storetarget' => 'rcmail_store_target_selection', 'addressbooks' => 'rcmail_addressbook_list', @@ -780,12 +787,13 @@ function rcmail_prepare_message_body() unset($plugin); // add blocked.gif attachment (#1486516) - if ($isHtml && preg_match('#<img src="\./program/resources/blocked\.gif"#', $body)) { - if ($attachment = rcmail_save_image('program/resources/blocked.gif', 'image/gif')) { + if ($isHtml && preg_match('#<img src="program/resources/blocked\.gif"#', $body)) { + $content = $RCMAIL->get_resource_content('blocked.gif'); + if ($content && ($attachment = rcmail_save_image('blocked.gif', 'image/gif', $content))) { $COMPOSE['attachments'][$attachment['id']] = $attachment; $url = sprintf('%s&_id=%s&_action=display-attachment&_file=rcmfile%s', $RCMAIL->comm_path, $COMPOSE['id'], $attachment['id']); - $body = preg_replace('#\./program/resources/blocked\.gif#', $url, $body); + $body = preg_replace('#program/resources/blocked\.gif#', $url, $body); } } @@ -1399,18 +1407,31 @@ function rcmail_save_attachment(&$message, $pid) return false; } -function rcmail_save_image($path, $mimetype='') +function rcmail_save_image($path, $mimetype = '', $data = null) { global $COMPOSE; // handle attachments in memory - $data = file_get_contents($path); + if (empty($data)) { + $data = file_get_contents($path); + $is_file = true; + } + $name = rcmail_basename($path); + if (empty($mimetype)) { + if ($is_file) { + $mimetype = rcube_mime::file_content_type($path, $name); + } + else { + $mimetype = rcube_mime::file_content_type($data, $name, 'application/octet-stream', true); + } + } + $attachment = array( 'group' => $COMPOSE['id'], 'name' => $name, - 'mimetype' => $mimetype ? $mimetype : rcube_mime::file_content_type($path, $name), + 'mimetype' => $mimetype, 'data' => $data, 'size' => strlen($data), ); @@ -1642,7 +1663,7 @@ function rcmail_priority_selector($attrib) } -function rcmail_receipt_checkbox($attrib) +function rcmail_mdn_checkbox($attrib) { global $RCMAIL, $MESSAGE, $compose_mode; @@ -1652,13 +1673,13 @@ function rcmail_receipt_checkbox($attrib) if (!isset($attrib['id'])) $attrib['id'] = 'receipt'; - $attrib['name'] = '_receipt'; + $attrib['name'] = '_mdn'; $attrib['value'] = '1'; $checkbox = new html_checkbox($attrib); - if (isset($_POST['_receipt'])) - $mdn_default = $_POST['_receipt']; + if (isset($_POST['_mdn'])) + $mdn_default = $_POST['_mdn']; else if (in_array($compose_mode, array(RCUBE_COMPOSE_DRAFT, RCUBE_COMPOSE_EDIT))) $mdn_default = (bool) $MESSAGE->headers->mdn_to; else diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index 6423636f0..48d989954 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -815,7 +815,7 @@ function rcmail_wash_html($html, $p, $cid_replaces) $wash_opts = array( 'show_washed' => false, 'allow_remote' => $p['safe'], - 'blocked_src' => "./program/resources/blocked.gif", + 'blocked_src' => 'program/resources/blocked.gif', 'charset' => RCUBE_CHARSET, 'cid_map' => $cid_replaces, 'html_elements' => array('body'), diff --git a/program/steps/mail/get.inc b/program/steps/mail/get.inc index 775349d1c..256af52b7 100644 --- a/program/steps/mail/get.inc +++ b/program/steps/mail/get.inc @@ -150,22 +150,22 @@ else if (strlen($part_id)) { // accept text/plain with any extension if ($real_mimetype == 'text/plain' && $real_mimetype == $mimetype) { - $file_extension = 'txt'; + $valid_extension = true; } - // ignore differences in text/* mimetypes. Filetype detection isn't very reliable here - if ($real_ctype_primary == 'text' && strpos($mimetype, $real_ctype_primary) === 0) { - $real_mimetype = $mimetype; + else if ($real_ctype_primary == 'text' && strpos($mimetype, $real_ctype_primary) === 0) { + $real_mimetype = $mimetype; + $valid_extension = true; } - - // get valid file extensions - $extensions = rcube_mime::get_mime_extensions($real_mimetype); - $valid_extension = (!$file_extension || in_array($file_extension, (array)$extensions)); - // ignore filename extension if mimeclass matches (#1489029) - if (!empty($_REQUEST['_mimeclass']) && $real_ctype_primary == $_REQUEST['_mimeclass']) { + else if (!empty($_REQUEST['_mimeclass']) && $real_ctype_primary == $_REQUEST['_mimeclass']) { $valid_extension = true; } + else { + // get valid file extensions + $extensions = rcube_mime::get_mime_extensions($real_mimetype); + $valid_extension = (!$file_extension || in_array($file_extension, (array)$extensions)); + } // fix mimetype for images wrongly declared as octet-stream if ($mimetype == 'application/octet-stream' && strpos($real_mimetype, 'image/') === 0 && $valid_extension) { @@ -183,10 +183,12 @@ else if (strlen($part_id)) { // send blocked.gif for expected images if (empty($_REQUEST['_mimewarning']) && strpos($mimetype, 'image/') === 0) { // Do not cache. Failure might be the result of a misconfiguration, thus real content should be returned once fixed. + $content = $RCMAIL->get_resource_content('blocked.gif'); $OUTPUT->nocacheing_headers(); header("Content-Type: image/gif"); header("Content-Transfer-Encoding: binary"); - readfile(INSTALL_PATH . 'program/resources/blocked.gif'); + header("Content-Length: " . strlen($content)); + echo $content; } else { // html warning with a button to load the file anyway $OUTPUT = new rcmail_html_page(); diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index c55e40064..5843de43f 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -144,7 +144,7 @@ if ($RCMAIL->config->get('http_received_header')) { $http_header .= $nldlm . ' via '; } - $host = $_SERVER['REMOTE_ADDR']; + $host = $_SERVER['REMOTE_ADDR']; $hostname = gethostbyaddr($host); if ($encrypt) { @@ -171,7 +171,7 @@ if ($RCMAIL->config->get('http_received_header')) { $headers['Date'] = $RCMAIL->user_date(); $headers['From'] = rcube_charset::convert($from_string, RCUBE_CHARSET, $message_charset); -$headers['To'] = $mailto; +$headers['To'] = $mailto; // additional recipients if (!empty($mailcc)) { @@ -188,6 +188,10 @@ if (($max_recipients = (int) $RCMAIL->config->get('max_recipients')) > 0) { } } +$dont_override = (array) $RCMAIL->config->get('dont_override'); +$mdn_enabled = in_array('mdn_default', $dont_override) ? $RCMAIL->config->get('mdn_default') : !empty($_POST['_mdn']); +$dsn_enabled = in_array('dsn_default', $dont_override) ? $RCMAIL->config->get('dsn_default') : !empty($_POST['_dsn']); + // add subject $headers['Subject'] = trim(rcube_utils::get_input_value('_subject', rcube_utils::INPUT_POST, TRUE, $message_charset)); @@ -228,7 +232,7 @@ if (!empty($_POST['_priority'])) { } } -if (!empty($_POST['_receipt'])) { +if ($mdn_enabled) { $headers['Return-Receipt-To'] = $from_string; $headers['Disposition-Notification-To'] = $from_string; } @@ -520,9 +524,7 @@ if (!$savedraft) { } // Handle Delivery Status Notification request - if (!empty($_POST['_dsn'])) { - $smtp_opts['dsn'] = true; - } + $smtp_opts['dsn'] = $dsn_enabled; $sent = $RCMAIL->deliver_message($MAIL_MIME, $from, $mailto, $smtp_error, $mailbody_file, $smtp_opts); @@ -682,11 +684,16 @@ if ($savedraft) { $OUTPUT->command('auto_save_start'); } else { + // Collect folders which could contain the composed message, + // we'll refresh the list if currently opened folder is one of them (#1490238) $folders = array(); - if ($COMPOSE['mode'] == 'reply' || $COMPOSE['mode'] == 'forward') { + if (in_array($COMPOSE['mode'], array('reply', 'forward', 'draft'))) { $folders[] = $COMPOSE['mailbox']; } + if (!empty($COMPOSE['param']['draft_uid']) && $drafts_mbox) { + $folders[] = $drafts_mbox; + } rcmail_compose_cleanup($COMPOSE_ID); $OUTPUT->command('remove_compose_data', $COMPOSE_ID); @@ -758,8 +765,10 @@ function rcmail_fix_emoticon_paths($mime_message) // 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(); @@ -772,12 +781,14 @@ function rcmail_fix_emoticon_paths($mime_message) // 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); |