summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2008-06-20 11:40:05 +0000
committerthomascube <thomas@roundcube.net>2008-06-20 11:40:05 +0000
commitfde466c58c004e8f7eff7b59c78f62eef250cde9 (patch)
treed46360c24b111482b27f0a14a4ab821e3cfd4d7a
parent2da368e6633ae4dec5d9b02ec3f4b693ffc9fb76 (diff)
Urlencode mail recipients for storing in session + little code cleanup
-rw-r--r--program/include/main.inc13
-rw-r--r--program/include/rcmail.php13
-rw-r--r--program/include/rcube_json_output.php2
-rw-r--r--program/steps/addressbook/mailto.inc4
-rw-r--r--program/steps/mail/compose.inc2
5 files changed, 13 insertions, 21 deletions
diff --git a/program/include/main.inc b/program/include/main.inc
index a29978a5e..d84ca896a 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -128,18 +128,7 @@ function rcmail_overwrite_action($action)
function rcmail_url($action, $p=array(), $task=null)
{
$app = rcmail::get_instance();
-
- $qstring = '';
- $base = $app->comm_path;
-
- if ($task && in_array($task, rcmail::$main_tasks))
- $base = ereg_replace('_task=[a-z]+', '_task='.$task, $app->comm_path);
-
- if (is_array($p))
- foreach ($p as $key => $val)
- $qstring .= '&'.urlencode($key).'='.urlencode($val);
-
- return $base . ($action ? '&_action='.$action : '') . $qstring;
+ return $app->url((array)$p + array('_action' => $action, 'task' => $task));
}
diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 7c12ef779..c2ad9cf87 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -830,13 +830,16 @@ class rcmail
public function url($p)
{
if (!is_array($p))
- $p = array('action' => @func_get_arg(0));
-
- $url = $p['task'] ? './?_task=' . $p['task'] : $this->comm_path;
- unset($p['task']);
+ $p = array('_action' => @func_get_arg(0));
+ if ($p['task'] && in_array($p['task'], rcmail::$main_tasks))
+ $url = './?_task='.$p['task'];
+ else
+ $url = $this->comm_path;
+
+ unset($p['task']);
foreach ($p as $par => $val)
- $url .= sprintf('&%s=%s', urlencode($par), urlencode($val));
+ $url .= '&'.urlencode($par).'='.urlencode($val);
return $url;
}
diff --git a/program/include/rcube_json_output.php b/program/include/rcube_json_output.php
index 2f65c19e9..e170445e5 100644
--- a/program/include/rcube_json_output.php
+++ b/program/include/rcube_json_output.php
@@ -169,7 +169,7 @@ class rcube_json_output
* @param mixed Either a string with the action or url parameters as key-value pairs
* @see rcmail::url()
*/
- public function redirect($p = array(), $delay = 0)
+ public function redirect($p = array(), $delay = 1)
{
$location = rcmail::get_instance()->url($p);
$this->remote_response("window.setTimeout(\"location.href='{$location}'\", $delay);");
diff --git a/program/steps/addressbook/mailto.inc b/program/steps/addressbook/mailto.inc
index 101b7c043..90a779644 100644
--- a/program/steps/addressbook/mailto.inc
+++ b/program/steps/addressbook/mailto.inc
@@ -37,8 +37,8 @@ if (!empty($mailto))
{
$mailto_str = join(', ', $mailto);
$mailto_id = substr(md5($mailto_str), 0, 16);
- $_SESSION['mailto'][$mailto_id] = $mailto_str;
- $OUTPUT->command('redirect', rcmail_url('compose', array('_mailto' => $mailto_id), 'mail'));
+ $_SESSION['mailto'][$mailto_id] = urlencode($mailto_str);
+ $OUTPUT->redirect(array('task' => 'mail', '_action' => 'compose', '_mailto' => $mailto_id));
}
else
$OUTPUT->show_message('nocontactsfound', 'warning');
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 607cf9b05..800a9de85 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -135,7 +135,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 = $_SESSION['mailto'][$mailto_id];
+ $fvalue = urldecode($_SESSION['mailto'][$mailto_id]);
else if (!empty($_SESSION['compose']['param']['_to']))
$fvalue = $_SESSION['compose']['param']['_to'];