| | |
| | | if (!is_array($COMPOSE)) { |
| | | // Infinite redirect prevention in case of broken session (#1487028) |
| | | if ($COMPOSE_ID) { |
| | | rcube::raise_error(array('code' => 500, 'type' => 'php', |
| | | 'file' => __FILE__, 'line' => __LINE__, |
| | | 'message' => "Invalid compose ID"), true, true); |
| | | // if we know the message with specified ID was already sent |
| | | // we can ignore the error and compose a new message (#1490009) |
| | | if ($COMPOSE_ID != $_SESSION['last_compose_session']) { |
| | | rcube::raise_error(array('code' => 450), false, true); |
| | | } |
| | | } |
| | | |
| | | $COMPOSE_ID = uniqid(mt_rand()); |
| | |
| | | // #1486037: remove "mailto:" prefix |
| | | $COMPOSE['param']['to'] = preg_replace('/^mailto:/i', '', $mailto[0]); |
| | | // #1490346: decode the recipient address |
| | | $COMPOSE['param']['to'] = urldecode($COMPOSE['param']['to']); |
| | | // #1490510: use raw encoding for correct "+" character handling as specified in RFC6068 |
| | | $COMPOSE['param']['to'] = rawurldecode($COMPOSE['param']['to']); |
| | | |
| | | // Supported case-insensitive tokens in mailto URL |
| | | $url_tokens = array('to', 'cc', 'bcc', 'reply-to', 'in-reply-to', 'references', 'subject', 'body'); |
| | |
| | | $fvalue .= (!empty($fvalue) ? $separator : '') . $v; |
| | | } |
| | | // Use Sender header (#1489011) |
| | | if (($v = $MESSAGE->headers->get('Sender', false)) && strpos($v, '-bounces@') === false) { |
| | | $fvalue .= (!empty($fvalue) ? $separator : '') . $v; |
| | | if ($v = $MESSAGE->headers->get('Sender', false)) { |
| | | // Skip common mailing lists addresses: *-bounces@ and *-request@ (#1490452) |
| | | if (empty($MESSAGE->headers->others['list-post']) || !preg_match('/-(bounces|request)@/', $v)) { |
| | | $fvalue .= (!empty($fvalue) ? $separator : '') . $v; |
| | | } |
| | | } |
| | | |
| | | // When To: and Reply-To: are the same we add From: address to the list (#1489037) |
| | |
| | | |
| | | function rcmail_compose_editor_mode() |
| | | { |
| | | global $RCMAIL; |
| | | global $RCMAIL, $COMPOSE; |
| | | static $useHtml; |
| | | |
| | | if ($useHtml !== null) { |
| | |
| | | if ($bodyIsHtml) { |
| | | $body = rcmail_wash_html($body, array('safe' => 1), $cid_map); |
| | | |
| | | // remove comments (produced by washtml) |
| | | $body = preg_replace('/<!--[^>]+-->/', '', $body); |
| | | // cleanup |
| | | $body = preg_replace(array( |
| | | // remove comments (produced by washtml) |
| | | '/<!--[^>]+-->/', |
| | | // remove <body> tags |
| | | '/<body([^>]*)>/i', |
| | | '/<\/body>/i', |
| | | // convert TinyMCE's empty-line sequence (#1490463) |
| | | '/<p>\xC2\xA0<\/p>/', |
| | | ), |
| | | array( |
| | | '', |
| | | '', |
| | | '', |
| | | '<p><br /></p>', |
| | | ), |
| | | $body |
| | | ); |
| | | |
| | | // replace cid with href in inline images links |
| | | if (!empty($cid_map)) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Creates reply subject by removing common subject |
| | | * prefixes/suffixes from the original message subject |
| | | */ |
| | | function rcmail_reply_subject($subject) |
| | | { |
| | | $subject = trim($subject); |
| | | |
| | | // replace Re:, Re[x]:, Re-x (#1490497) |
| | | $prefix = '/^(re:|re\[\d\]:|re-\d:)\s*/i'; |
| | | do { |
| | | $subject = preg_replace($prefix, '', $subject, -1, $count); |
| | | } |
| | | while ($count); |
| | | |
| | | // replace (was: ...) (#1489375) |
| | | $subject = preg_replace('/\s*\([wW]as:[^\)]+\)\s*$/', '', $subject); |
| | | |
| | | return 'Re: ' . $subject; |
| | | } |
| | | |
| | | function rcmail_compose_subject($attrib) |
| | | { |
| | | global $MESSAGE, $COMPOSE; |
| | |
| | | } |
| | | // create a reply-subject |
| | | else if ($COMPOSE['mode'] == RCUBE_COMPOSE_REPLY) { |
| | | if (preg_match('/^re:/i', $MESSAGE->subject)) |
| | | $subject = $MESSAGE->subject; |
| | | else |
| | | $subject = 'Re: '.$MESSAGE->subject; |
| | | |
| | | // replace (was: ...) (#1489375) |
| | | $subject = preg_replace('/\s*\([wW]as:[^\)]+\)\s*$/', '', $subject); |
| | | $subject = rcmail_reply_subject($MESSAGE->subject); |
| | | } |
| | | // create a forward-subject |
| | | else if ($COMPOSE['mode'] == RCUBE_COMPOSE_FORWARD) { |
| | |
| | | |
| | | return $out; |
| | | } |
| | | |
| | | |
| | | function rcmail_compose_attachment_list($attrib) |
| | | { |