From 5f314dafe9798b38c30301417cdfb70dfaca0fae Mon Sep 17 00:00:00 2001 From: thomascube Date: Fri, 5 Sep 2008 11:38:09 +0000 Subject: [PATCH] Correctly handle options in mailto-links (#1485228) --- CHANGELOG | 1 + program/steps/mail/compose.inc | 41 +++++++++++++++++++++++----------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index cbe7dcdc8..9eba18720 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ CHANGELOG RoundCube Webmail - Allowed max. attachment size now indicated in compose screen (#1485030) - Also capture backspace key in list mode (#1484566) - Allow application/pgp parts to be displayed (#1484753) +- Correctly handle options in mailto-links (#1485228) 2008/09/04 (alec) ---------- diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index 62ee14703..783ac98ef 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -65,6 +65,17 @@ if (!is_array($_SESSION['compose']) || $_SESSION['compose']['id'] != get_input_v rcmail_compose_cleanup(); $_SESSION['compose'] = array('id' => uniqid(rand()), 'param' => array_map('strip_tags', $_GET)); + // process values like "mailto:foo@bar.com?subject=new+message&cc=another" + if ($_SESSION['compose']['param']['_to']) { + $mailto = explode('?', $_SESSION['compose']['param']['_to']); + if (count($mailto) > 1) { + $_SESSION['compose']['param']['_to'] = $mailto[0]; + parse_str($mailto[1], $query); + foreach ($query as $f => $val) + $_SESSION['compose']['param']["_$f"] = $val; + } + } + // redirect to a unique URL with all parameters stored in session $OUTPUT->redirect(array('_action' => 'compose', '_id' => $_SESSION['compose']['id'])); } @@ -143,9 +154,7 @@ function rcmail_compose_headers($attrib) // we have a set of recipients stored is session if (($mailto_id = $_SESSION['compose']['param']['_mailto']) && $_SESSION['mailto'][$mailto_id]) $fvalue = urldecode($_SESSION['mailto'][$mailto_id]); - else if (!empty($_SESSION['compose']['param']['_to'])) - $fvalue = $_SESSION['compose']['param']['_to']; - + case 'cc': if (!$fname) { @@ -168,11 +177,13 @@ function rcmail_compose_headers($attrib) $fname = '_replyto'; $allow_attrib = array('id', 'class', 'style', 'size', 'tabindex'); $field_type = 'html_inputfield'; - break; + break; } if ($fname && !empty($_POST[$fname])) $fvalue = get_input_value($fname, RCUBE_INPUT_POST, TRUE); + else if ($fname && !$fvalue && !empty($_SESSION['compose']['param'][$fname])) + $fvalue = $_SESSION['compose']['param'][$fname]; else if ($header && $compose_mode == RCUBE_COMPOSE_REPLY) { @@ -386,6 +397,10 @@ function rcmail_compose_body($attrib) else if ($compose_mode == RCUBE_COMPOSE_DRAFT) $body = rcmail_create_draft_body($body, $isHtml); } + else if (!empty($_SESSION['compose']['param']['_body'])) + { + $body = $_SESSION['compose']['param']['_body']; + } $lang = $tinylang = strtolower(substr($_SESSION['language'], 0, 2)); if (!file_exists(INSTALL_PATH . 'program/js/tiny_mce/langs/'.$tinylang.'.js')) @@ -608,30 +623,30 @@ function rcmail_compose_subject($attrib) $subject = ''; // use subject from post - if (isset($_POST['_subject'])) + if (isset($_POST['_subject'])) { $subject = get_input_value('_subject', RCUBE_INPUT_POST, TRUE); - + } // create a reply-subject - else if ($compose_mode == RCUBE_COMPOSE_REPLY) - { + else if ($compose_mode == RCUBE_COMPOSE_REPLY) { if (eregi('^re:', $MESSAGE->subject)) $subject = $MESSAGE->subject; else $subject = 'Re: '.$MESSAGE->subject; } - // create a forward-subject - else if ($compose_mode == RCUBE_COMPOSE_FORWARD) - { + else if ($compose_mode == RCUBE_COMPOSE_FORWARD) { if (eregi('^fwd:', $MESSAGE->subject)) $subject = $MESSAGE->subject; else $subject = 'Fwd: '.$MESSAGE->subject; } - // creeate a draft-subject - else if ($compose_mode == RCUBE_COMPOSE_DRAFT) + else if ($compose_mode == RCUBE_COMPOSE_DRAFT) { $subject = $MESSAGE->subject; + } + else if (!empty($_SESSION['compose']['param']['_subject'])) { + $subject = $_SESSION['compose']['param']['_subject']; + } $out = $form_start ? "$form_start\n" : ''; $out .= $textfield->show($subject);