summaryrefslogtreecommitdiff
path: root/program/steps/mail
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2006-12-29 21:06:39 +0000
committerthomascube <thomas@roundcube.net>2006-12-29 21:06:39 +0000
commit86df1529feb4b7eb1a9721baa194518bacbfd8ff (patch)
tree380827ed01c3e3e3a3253d0b00c350b467186a25 /program/steps/mail
parent3b12aeeeca89bbc3d8cc5342beb07643067e3760 (diff)
Error handling for attachment uploads; multibyte-safe string functions; XSS improvements
Diffstat (limited to 'program/steps/mail')
-rw-r--r--program/steps/mail/compose.inc12
-rw-r--r--program/steps/mail/func.inc2
-rw-r--r--program/steps/mail/upload.inc10
3 files changed, 19 insertions, 5 deletions
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index a50b1ecf0..1c2639d9b 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -46,12 +46,16 @@ if ($_action=='remove-attachment' && preg_match('/^rcmfile([0-9]+)$/', $_GET['_f
$MESSAGE_FORM = NULL;
$MESSAGE = NULL;
-// nothing below is called during message composition, only at "new/forward/reply/draft" initialization
-// since there are many ways to leave the compose page improperly, it seems necessary to clean-up an old
+// Nothing below is called during message composition, only at "new/forward/reply/draft" initialization or
+// if a compose-ID is given (i.e. when the compose step is opened in a new window/tab).
+// Since there are many ways to leave the compose page improperly, it seems necessary to clean-up an old
// compose when a "new/forward/reply/draft" is called - otherwise the old session attachments will appear
-rcmail_compose_cleanup();
-$_SESSION['compose'] = array('id' => uniqid(rand()));
+if (!is_array($_SESSION['compose']) || $_SESSION['compose']['id'] != get_input_value('_id', RCUBE_INPUT_GET))
+ {
+ rcmail_compose_cleanup();
+ $_SESSION['compose'] = array('id' => uniqid(rand()));
+ }
// add some labels to client
rcube_add_label('nosubject', 'norecipientwarning', 'nosubjectwarning', 'nobodywarning', 'notsentwarning', 'savingmessage', 'sendingmessage', 'messagesaved', 'converting');
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index dea6c040e..b8c391aae 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -1214,7 +1214,7 @@ function rcmail_mod_html_body($body, $container_id)
while ($body != $prev_body)
{
$prev_body = $body;
- $body = preg_replace('/(<[^!][^>]*?\s)(on\w+?)(=[^>]*?>)/im', '$1__removed=$3', $body);
+ $body = preg_replace('/(<[^!][^>]*?\s)(on[^=]+)(=[^>]*?>)/im', '$1__removed=$3', $body);
$body = preg_replace('/(<[^!][^>]*?\shref=["\']?)(javascript:)([^>]*?>)/im', '$1null:$3', $body);
}
diff --git a/program/steps/mail/upload.inc b/program/steps/mail/upload.inc
index 0d9761e44..06ed26591 100644
--- a/program/steps/mail/upload.inc
+++ b/program/steps/mail/upload.inc
@@ -65,6 +65,16 @@ foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath)
$id,
$content);
}
+ else // upload failed
+ {
+ $err = $_FILES['_attachments']['error'][$i];
+ if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE)
+ $msg = rcube_label(array('name' => 'filesizeerror', 'vars' => array('size' => show_bytes(parse_bytes(ini_get('upload_max_filesize'))))));
+ else
+ $msg = rcube_label('fileuploaderror');
+
+ $response = sprintf("parent.%s.display_message('%s', 'error');", $JS_OBJECT_NAME, JQ($msg));
+ }
}