summaryrefslogtreecommitdiff
path: root/program/steps/mail
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps/mail')
-rw-r--r--program/steps/mail/attachments.inc7
-rw-r--r--program/steps/mail/autocomplete.inc7
-rw-r--r--program/steps/mail/compose.inc6
-rw-r--r--program/steps/mail/func.inc19
-rw-r--r--program/steps/mail/list.inc4
-rw-r--r--program/steps/mail/sendmail.inc10
6 files changed, 35 insertions, 18 deletions
diff --git a/program/steps/mail/attachments.inc b/program/steps/mail/attachments.inc
index b0a2a7e81..f6e29f9d7 100644
--- a/program/steps/mail/attachments.inc
+++ b/program/steps/mail/attachments.inc
@@ -63,6 +63,11 @@ if ($RCMAIL->action=='display-attachment')
// use common temp dir for file uploads
$temp_dir = unslashify($CONFIG['temp_dir']);
+// #1484529: we need absolute path on Windows for move_uploaded_file()
+if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
+ $temp_dir = realpath($temp_dir);
+}
+
if (!is_array($_SESSION['compose']['attachments'])) {
$_SESSION['compose']['attachments'] = array();
}
@@ -73,7 +78,7 @@ $OUTPUT->reset();
if (is_array($_FILES['_attachments']['tmp_name'])) {
foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath) {
$tmpfname = tempnam($temp_dir, 'rcmAttmnt');
- if (move_uploaded_file($filepath, $tmpfname)) {
+ if (move_uploaded_file($filepath, $tmpfname) && file_exists($tmpfname)) {
$id = count($_SESSION['compose']['attachments']);
$_SESSION['compose']['attachments'][] = array(
'name' => $_FILES['_attachments']['name'][$i],
diff --git a/program/steps/mail/autocomplete.inc b/program/steps/mail/autocomplete.inc
index 26acc88c2..b1aba7d62 100644
--- a/program/steps/mail/autocomplete.inc
+++ b/program/steps/mail/autocomplete.inc
@@ -19,7 +19,7 @@
*/
-$MAXNUM = 15; // same limit as in app.js
+$MAXNUM = 15;
$contacts = array();
$book_types = (array) $RCMAIL->config->get('autocomplete_addressbooks', 'sql');
@@ -33,12 +33,11 @@ if ($book_types && $search = get_input_value('_search', RCUBE_INPUT_POST)) {
while ($sql_arr = $result->iterate()) {
if (stripos((string)$sql_arr['email'], $search) !== false || stripos((string)$sql_arr['name'], $search) !== false) {
$contacts[] = format_email_recipient($sql_arr['email'], $sql_arr['name']);
+ if (count($contacts) >= $MAXNUM)
+ break 2;
}
}
}
-
- if (count($contacts) >= $MAXNUM)
- break;
}
sort($contacts);
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 1b83b1ed4..49c4c3011 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -70,8 +70,10 @@ if ($msg_uid = $_SESSION['compose']['param']['_reply_uid'])
$compose_mode = RCUBE_COMPOSE_REPLY;
else if ($msg_uid = $_SESSION['compose']['param']['_forward_uid'])
$compose_mode = RCUBE_COMPOSE_FORWARD;
-else if ($msg_uid = $_SESSION['compose']['param']['_draft_uid'])
+else if ($msg_uid = $_SESSION['compose']['param']['_draft_uid']) {
+ $RCMAIL->imap->set_mailbox($CONFIG['drafts_mbox']);
$compose_mode = RCUBE_COMPOSE_DRAFT;
+}
if (!empty($msg_uid))
{
@@ -488,7 +490,7 @@ function rcmail_create_reply_body($body, $bodyIsHtml)
}
// add title line(s)
- $prefix = wordwrap(sprintf("On %s, %s wrote:\n",
+ $prefix = rc_wordwrap(sprintf("On %s, %s wrote:\n",
$MESSAGE->headers->date,
$MESSAGE->get_header('from')), 76);
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 79e148d8a..8931cfa4e 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -660,7 +660,7 @@ function rcmail_wash_html($html, $p = array(), $cid_replaces)
'/<title>.*<\/title>/i', // PHP bug #32547 workaround: remove title tag
'/<html[^>]*>/im', // malformed html: remove html tags (#1485139)
'/<\/html>/i', // malformed html: remove html tags (#1485139)
- '/^[\xFE\xFF\xBB\xBF\x00]+((?:<\!doctype|\<html))/im', // remove byte-order mark (only outlook?)
+ '/^(\0\0\xFE\xFF|\xFF\xFE\0\0|\xFE\xFF|\xFF\xFE|\xEF\xBB\xBF)/', // byte-order mark (only outlook?)
);
$html_replace = array(
'\\1'.' &nbsp; '.'\\3',
@@ -669,7 +669,7 @@ function rcmail_wash_html($html, $p = array(), $cid_replaces)
'',
'',
'',
- '\\1',
+ '',
);
$html = preg_replace($html_search, $html_replace, $html);
@@ -1179,7 +1179,7 @@ function rcmail_wrap_quoted($text, $max = 76)
$prefix = substr($line, 0, $length);
// Remove '> ' from the line, then wordwrap() the line
- $line = wordwrap(substr($line, $length), $max - $length);
+ $line = rc_wordwrap(substr($line, $length), $max - $length);
// Rebuild the line with '> ' at the beginning of each 'subline'
$newline = '';
@@ -1191,7 +1191,7 @@ function rcmail_wrap_quoted($text, $max = 76)
$line = rtrim($newline);
}
else {
- $line = wordwrap($line, $max);
+ $line = rc_wordwrap($line, $max);
}
}
@@ -1308,7 +1308,14 @@ function rcmail_deliver_message(&$message, $from, $mailto)
// reset stored headers and overwrite
$message->_headers = array();
$header_str = $message->txtHeaders($headers_php);
-
+
+ // #1485779
+ if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
+ if (preg_match_all('/<([^@]+@[^>]+)>/', $headers_enc['To'], $m)) {
+ $headers_enc['To'] = implode(', ', $m[1]);
+ }
+ }
+
if (ini_get('safe_mode'))
$sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str);
else
@@ -1390,7 +1397,7 @@ function rcmail_send_mdn($uid)
"Disposition: manual-action/MDN-sent-manually; displayed\r\n";
$compose->headers($headers);
- $compose->setTXTBody(wordwrap($body, 75, "\r\n"));
+ $compose->setTXTBody(rc_wordwrap($body, 75, "\r\n"));
$compose->addAttachment($report, 'message/disposition-notification', 'MDNPart2.txt', false, '7bit', 'inline');
$sent = rcmail_deliver_message($compose, $identity['email'], $mailto);
diff --git a/program/steps/mail/list.inc b/program/steps/mail/list.inc
index 5cc2a574d..d32e93996 100644
--- a/program/steps/mail/list.inc
+++ b/program/steps/mail/list.inc
@@ -19,6 +19,10 @@
*/
+if (!$OUTPUT->ajax_call) {
+ return;
+}
+
// is there a sort type for this request?
if ($sort = get_input_value('_sort', RCUBE_INPUT_GET))
{
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index eb81fc9ad..9607619e9 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -302,10 +302,10 @@ if ($isHtml)
$MAIL_MIME->setHTMLBody($message_body . ($footer ? "\r\n<pre>".$footer.'</pre>' : ''));
// add a plain text version of the e-mail as an alternative part.
- $h2t = new html2text($message_body);
- $plainTextPart = $h2t->get_text() . ($footer ? "\r\n".$footer : '');
+ $h2t = new html2text($message_body, false, true, 0);
+ $plainTextPart = rc_wordwrap($h2t->get_text(), 75, "\r\n"). ($footer ? "\r\n".$footer : '');
$plainTextPart = wordwrap($plainTextPart, 998, "\r\n", true);
- if (!strlen($plainTextPart))
+ if (!strlen($plainTextPart))
{
// empty message body breaks attachment handling in drafts
$plainTextPart = "\r\n";
@@ -317,7 +317,7 @@ if ($isHtml)
}
else
{
- $message_body = wordwrap($message_body, 75, "\r\n");
+ $message_body = rc_wordwrap($message_body, 75, "\r\n");
if ($footer)
$message_body .= "\r\n" . $footer;
$message_body = wordwrap($message_body, 998, "\r\n", true);
@@ -342,7 +342,7 @@ if (is_array($_SESSION['compose']['attachments']))
if ($isHtml && ($match > 0))
{
$message_body = preg_replace($dispurl, ' src="'.$attachment['name'].'" ', $message_body);
- $MAIL_MIME->setHTMLBody($message_body. ($footer ? "\r\n<pre>".$footer.'</pre>' : ''));
+ $MAIL_MIME->setHTMLBody($message_body);
$MAIL_MIME->addHTMLImage($attachment['path'], $attachment['mimetype'], $attachment['name']);
}
else