X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fcompose.php;h=ee8bcaaa264d04fb49353f0b4faae8dff42d48bf;hb=e4f360ed1638dd32300ac9e42fe801375fe6adf2;hp=09cf6c3895735d8ba88c60b2f8058c3f9133f4ff;hpb=3243368996ca5c6beec0a4f4153aa7db776e322b;p=squirrelmail.git
diff --git a/src/compose.php b/src/compose.php
index 09cf6c38..ee8bcaaa 100644
--- a/src/compose.php
+++ b/src/compose.php
@@ -10,7 +10,7 @@
* - Send mail
* - Save As Draft
*
- * @copyright 1999-2012 The SquirrelMail Project Team
+ * @copyright 1999-2016 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
* @package squirrelmail
@@ -41,6 +41,7 @@ require_once(SM_PATH . 'class/deliver/Deliver.class.php');
require_once(SM_PATH . 'functions/addressbook.php');
require_once(SM_PATH . 'functions/forms.php');
require_once(SM_PATH . 'functions/identity.php');
+global $imap_stream_options; // in case not defined in config
/* --------------------- Get globals ------------------------------------- */
@@ -72,6 +73,7 @@ if (isset($send) && $send) {
}
sqgetGlobalVar('session',$session, $SQ_GLOBAL);
sqgetGlobalVar('mailbox',$mailbox, $SQ_GLOBAL);
+sqgetGlobalVar('identity',$orig_identity, $SQ_GLOBAL);
if(!sqgetGlobalVar('identity',$identity, $SQ_GLOBAL)) {
$identity=0;
}
@@ -415,7 +417,7 @@ if ($draft) {
// validate security token
//
- sm_validate_security_token($submitted_token, 3600, TRUE);
+ sm_validate_security_token($submitted_token, -1, TRUE);
/*
* Set $default_charset to correspond with the user's selection
@@ -429,7 +431,7 @@ if ($draft) {
$draft_message = _("Draft Email Saved");
/* If this is a resumed draft, then delete the original */
if(isset($delete_draft)) {
- $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, false);
+ $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, false, $imap_stream_options);
sqimap_mailbox_select($imap_stream, $draft_folder);
// force bypass_trash=true because message should be saved when deliverMessage() returns true.
// in current implementation of sqimap_msgs_list_flag() single message id can
@@ -474,7 +476,7 @@ if ($send) {
// validate security token
//
- sm_validate_security_token($submitted_token, 3600, TRUE);
+ sm_validate_security_token($submitted_token, -1, TRUE);
if (isset($_FILES['attachfile']) &&
$_FILES['attachfile']['tmp_name'] &&
@@ -542,7 +544,7 @@ if ($send) {
/* if it is resumed draft, delete draft message */
if ( isset($delete_draft)) {
- $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, false);
+ $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, false, $imap_stream_options);
sqimap_mailbox_select($imap_stream, $draft_folder);
// bypass_trash=true because message should be saved when deliverMessage() returns true.
// in current implementation of sqimap_msgs_list_flag() single message id can
@@ -601,7 +603,7 @@ if ($send) {
// validate security token
//
- sm_validate_security_token($submitted_token, 3600, TRUE);
+ sm_validate_security_token($submitted_token, -1, TRUE);
if ($compose_new_win == '1') {
compose_Header($color, $mailbox);
@@ -650,7 +652,7 @@ if ($send) {
// validate security token
//
- sm_validate_security_token($submitted_token, 3600, TRUE);
+ sm_validate_security_token($submitted_token, -1, TRUE);
if ($compose_new_win == '1') {
compose_Header($color, $mailbox);
@@ -666,7 +668,7 @@ elseif (isset($sigappend)) {
// validate security token
//
- sm_validate_security_token($submitted_token, 3600, TRUE);
+ sm_validate_security_token($submitted_token, -1, TRUE);
$signature = $idents[$identity]['signature'];
@@ -681,7 +683,7 @@ elseif (isset($sigappend)) {
// validate security token
//
- sm_validate_security_token($submitted_token, 3600, TRUE);
+ sm_validate_security_token($submitted_token, -1, TRUE);
if ($compose_new_win == '1') {
compose_Header($color, $mailbox);
@@ -752,6 +754,12 @@ elseif (isset($sigappend)) {
if (isset($subject)) {
$values['subject'] = $subject;
}
+ if (isset($mailprio)) {
+ $values['mailprio'] = $mailprio;
+ }
+ if (isset($orig_identity)) {
+ $values['identity'] = $orig_identity;
+ }
showInputForm($session, $values);
}
@@ -773,10 +781,10 @@ function getforwardSubject($subject)
function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $session='') {
global $editor_size, $default_use_priority, $body, $idents,
$use_signature, $data_dir, $username,
- $key, $imapServerAddress, $imapPort,
+ $key, $imapServerAddress, $imapPort, $imap_stream_options,
$composeMessage, $body_quote, $request_mdn, $request_dr,
$mdn_user_support, $languages, $squirrelmail_language,
- $default_charset;
+ $default_charset, $do_not_reply_to_self;
/*
* Set $default_charset to correspond with the user's selection
@@ -790,7 +798,7 @@ function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $se
if ($passed_id) {
$imapConnection = sqimap_login($username, false, $imapServerAddress,
- $imapPort, 0);
+ $imapPort, 0, $imap_stream_options);
sqimap_mailbox_select($imapConnection, $mailbox);
$message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
@@ -884,16 +892,11 @@ function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $se
if (count($idents) > 1) {
foreach($idents as $nr=>$data) {
$enc_from_name = '"'.$data['full_name'].'" <'. $data['email_address'].'>';
- if(strtolower($enc_from_name) == strtolower($orig_from)) {
- $identity = $nr;
- // don't stop! need to build $identities array for idents match below
- //break;
- }
$identities[] = $enc_from_name;
}
$identity_match = $orig_header->findAddress($identities);
- if ($identity_match) {
+ if ($identity_match !== FALSE) {
$identity = $identity_match;
}
}
@@ -980,6 +983,82 @@ function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $se
}
$send_to = decodeHeader($send_to,false,false,true);
$send_to = str_replace('""', '"', $send_to);
+
+
+ // If user doesn't want replies to her own messages
+ // going back to herself (instead send again to the
+ // original recipient of the message being replied to),
+ // then iterate through identities, checking if the TO
+ // field is one of them (if the reply is to ourselves)
+ //
+ // Note we don't bother if the original message doesn't
+ // have anything in the TO field itself (because that's
+ // what we use if we change the recipient to be that of
+ // the previous message)
+ //
+ if ($do_not_reply_to_self && !empty($orig_header->to)) {
+
+ $orig_to = '';
+
+ foreach($idents as $id) {
+
+ if (!empty($id['email_address'])
+ && strpos($send_to, $id['email_address']) !== FALSE) {
+
+ // if this is a reply-all, the original recipient
+ // is already in the CC field, so we can just blank
+ // the recipient (TO field) (as long as the CC field
+ // isn't empty that is)... but then move the CC into
+ // the TO, so TO isn't empty
+ //
+ if ($action == 'reply_all' && !empty($send_to_cc)) {
+ $orig_to = $send_to_cc;
+ $send_to_cc = '';
+ break;
+ }
+
+ $orig_to = $orig_header->to;
+ if (is_array($orig_to) && count($orig_to)) {
+ $orig_to = $orig_header->getAddr_s('to', ',', FALSE, TRUE);
+ } else if (is_object($orig_to)) { /* unneccesarry, just for failsafe purpose */
+ $orig_to = $orig_header->getAddr_s('to', ',', FALSE, TRUE);
+ } else {
+ $orig_to = '';
+ }
+ $orig_to = decodeHeader($orig_to,false,false,true);
+ $orig_to = str_replace('""', '"', $orig_to);
+
+ break;
+ }
+ }
+
+ // if the reply was addressed back to ourselves,
+ // we will send it to the TO of the previous message
+ //
+ if (!empty($orig_to)) {
+
+ $send_to = $orig_to;
+
+ // in this case, we also want to reset the FROM
+ // identity as well (it should match the original
+ // *FROM* header instead of TO or CC)
+ //
+ if (count($idents) > 1) {
+ $identity = '';
+ foreach($idents as $i => $id) {
+ if (!empty($id['email_address'])
+ && strpos($orig_from, $id['email_address']) !== FALSE) {
+ $identity = $i;
+ break;
+ }
+ }
+ }
+
+ }
+
+ }
+
+
$subject = decodeHeader($orig_header->subject,false,false,true);
$subject = str_replace('"', "'", $subject);
$subject = trim($subject);
@@ -1274,10 +1353,10 @@ function showInputForm ($session, $values=false) {
$oTemplate->assign('identity_def', $identity);
$oTemplate->assign('input_onfocus', 'onfocus="'.join(' ', $onfocus_array).'"');
- $oTemplate->assign('to', htmlspecialchars($send_to));
- $oTemplate->assign('cc', htmlspecialchars($send_to_cc));
- $oTemplate->assign('bcc', htmlspecialchars($send_to_bcc));
- $oTemplate->assign('subject', htmlspecialchars($subject));
+ $oTemplate->assign('to', sm_encode_html_special_chars($send_to));
+ $oTemplate->assign('cc', sm_encode_html_special_chars($send_to_cc));
+ $oTemplate->assign('bcc', sm_encode_html_special_chars($send_to_bcc));
+ $oTemplate->assign('subject', sm_encode_html_special_chars($subject));
// access keys...
//
@@ -1313,9 +1392,9 @@ function showInputForm ($session, $values=false) {
} else {
$body_str = "\n\n".($prefix_sig==true? "-- \n":'').decodeHeader($signature,false,false);
}
- $body_str .= "\n\n".htmlspecialchars(decodeHeader($body,false,false));
+ $body_str .= "\n\n".sm_encode_html_special_chars(decodeHeader($body,false,false));
} else {
- $body_str = "\n\n".htmlspecialchars(decodeHeader($body,false,false));
+ $body_str = "\n\n".sm_encode_html_special_chars(decodeHeader($body,false,false));
// FIXME: test is specific to ja_JP translation implementation. See above comments.
if ($default_charset == 'iso-2022-jp') {
$body_str .= "\n\n".($prefix_sig==true? "-- \n":'').mb_convert_encoding($signature, 'EUC-JP');
@@ -1324,7 +1403,7 @@ function showInputForm ($session, $values=false) {
}
}
} else {
- $body_str = htmlspecialchars(decodeHeader($body,false,false));
+ $body_str = sm_encode_html_special_chars(decodeHeader($body,false,false));
}
$oTemplate->assign('editor_width', (int)$editor_size);
@@ -1609,7 +1688,7 @@ function deliverMessage(&$composeMessage, $draft=false) {
$username, $identity, $idents, $data_dir,
$request_mdn, $request_dr, $default_charset, $useSendmail,
$domain, $action, $default_move_to_sent, $move_to_sent,
- $imapServerAddress, $imapPort, $sent_folder, $key;
+ $imapServerAddress, $imapPort, $imap_stream_options, $sent_folder, $key;
$rfc822_header = $composeMessage->rfc822_header;
@@ -1706,13 +1785,13 @@ function deliverMessage(&$composeMessage, $draft=false) {
if (!$useSendmail && !$draft) {
require_once(SM_PATH . 'class/deliver/Deliver_SMTP.class.php');
$deliver = new Deliver_SMTP();
- global $smtpServerAddress, $smtpPort, $pop_before_smtp, $pop_before_smtp_host;
+ global $smtpServerAddress, $smtpPort, $smtp_stream_options, $pop_before_smtp, $pop_before_smtp_host;
$authPop = (isset($pop_before_smtp) && $pop_before_smtp) ? true : false;
if (empty($pop_before_smtp_host)) $pop_before_smtp_host = $smtpServerAddress;
get_smtp_user($user, $pass);
$stream = $deliver->initStream($composeMessage,$domain,0,
- $smtpServerAddress, $smtpPort, $user, $pass, $authPop, $pop_before_smtp_host);
+ $smtpServerAddress, $smtpPort, $user, $pass, $authPop, $pop_before_smtp_host, $smtp_stream_options);
} elseif (!$draft) {
require_once(SM_PATH . 'class/deliver/Deliver_SendMail.class.php');
global $sendmail_path, $sendmail_args;
@@ -1729,7 +1808,7 @@ function deliverMessage(&$composeMessage, $draft=false) {
} elseif ($draft) {
global $draft_folder;
$imap_stream = sqimap_login($username, false, $imapServerAddress,
- $imapPort, 0);
+ $imapPort, 0, $imap_stream_options);
if (sqimap_mailbox_exists ($imap_stream, $draft_folder)) {
require_once(SM_PATH . 'class/deliver/Deliver_IMAP.class.php');
$imap_deliver = new Deliver_IMAP();
@@ -1739,7 +1818,7 @@ function deliverMessage(&$composeMessage, $draft=false) {
$composeMessage->purgeAttachments();
return $success;
} else {
- $msg = '
'.sprintf(_("Error: Draft folder %s does not exist."), htmlspecialchars($draft_folder));
+ $msg = '
'.sprintf(_("Error: Draft folder %s does not exist."), sm_encode_html_special_chars($draft_folder));
plain_error_message($msg);
return false;
}
@@ -1760,12 +1839,12 @@ function deliverMessage(&$composeMessage, $draft=false) {
$msg .= '
'
. _("Server replied:") . ' '
. (isset($deliver->dlv_ret_nr) ? $deliver->dlv_ret_nr . ' ' : '')
- . nl2br(htmlspecialchars($deliver->dlv_server_msg));
+ . nl2br(sm_encode_html_special_chars($deliver->dlv_server_msg));
}
plain_error_message($msg);
} else {
unset ($deliver);
- $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
+ $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0, $imap_stream_options);
// mark as replied or forwarded if applicable