summaryrefslogtreecommitdiff
path: root/program/steps/mail/get.inc
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps/mail/get.inc')
-rw-r--r--program/steps/mail/get.inc86
1 files changed, 12 insertions, 74 deletions
diff --git a/program/steps/mail/get.inc b/program/steps/mail/get.inc
index e0c4e2911..372757720 100644
--- a/program/steps/mail/get.inc
+++ b/program/steps/mail/get.inc
@@ -38,34 +38,19 @@ ob_end_clean();
// similar code as in program/steps/mail/show.inc
if (!empty($_GET['_uid'])) {
- $uid = get_input_value('_uid', RCUBE_INPUT_GET);
$RCMAIL->config->set('prefer_html', true);
- $MESSAGE = new rcube_message($uid);
+ $MESSAGE = new rcube_message(get_input_value('_uid', RCUBE_INPUT_GET));
}
// check connection status
check_storage_status();
-$part_id = get_input_value('_part', RCUBE_INPUT_GPC);
-
// show part page
if (!empty($_GET['_frame'])) {
- if ($part_id && ($part = $MESSAGE->mime_parts[$part_id])) {
- $filename = rcmail_attachment_name($part);
- $OUTPUT->set_pagetitle($filename);
+ if (($part_id = get_input_value('_part', RCUBE_INPUT_GPC)) && ($part = $MESSAGE->mime_parts[$part_id])) {
+ $OUTPUT->set_pagetitle(rcmail_attachment_name($part));
}
- // register UI objects
- $OUTPUT->add_handlers(array(
- 'messagepartframe' => 'rcmail_message_part_frame',
- 'messagepartcontrols' => 'rcmail_message_part_controls',
- ));
-
- $OUTPUT->set_env('mailbox', $RCMAIL->storage->get_folder());
- $OUTPUT->set_env('uid', $uid);
- $OUTPUT->set_env('part', $part_id);
- $OUTPUT->set_env('filename', $filename);
-
$OUTPUT->send('messagepart');
exit;
}
@@ -107,8 +92,9 @@ else if ($_GET['_thumb']) {
exit;
}
-else if (strlen($part_id)) {
- if ($part = $MESSAGE->mime_parts[$part_id]) {
+else if (strlen($pid = get_input_value('_part', RCUBE_INPUT_GET))) {
+
+ if ($part = $MESSAGE->mime_parts[$pid]) {
$mimetype = rcmail_fix_mimetype($part->mimetype);
// allow post-processing of the message body
@@ -134,7 +120,7 @@ else if (strlen($part_id)) {
$valid = $file_extension && in_array($file_extension, (array)$extensions) || !empty($_REQUEST['_mimeclass']);
// 2. detect the real mimetype of the attachment part and compare it with the stated mimetype and filename extension
- if ($valid || !$file_extension || $mimetype == 'application/octet-stream' || stripos($mimetype, 'text/') === 0) {
+ if ($valid || !$file_extension || $mimetype == 'application/octet-stream' || $mimetype == 'text/plain') {
if ($part->body) // part body is already loaded
$body = $part->body;
else if ($part->size && $part->size < 1024*1024) // load the entire part if it's small enough
@@ -189,8 +175,8 @@ else if (strlen($part_id)) {
rcube_label(array(
'name' => 'attachmentvalidationerror',
'vars' => array(
- 'expected' => $mimetype . ($file_extension ? " (.$file_extension)" : ''),
- 'detected' => $real_mimetype . ($extensions[0] ? " (.$extensions[0])" : ''),
+ 'expected' => $mimetype . ($file_extension ? "(.$file_extension)" : ''),
+ 'detected' => $real_mimetype . ($extensions[0] ? "(.$extensions[0])" : ''),
)
)) .
html::p(array('class' => 'rcmail-inline-buttons'),
@@ -233,6 +219,7 @@ else if (strlen($part_id)) {
header("Content-Transfer-Encoding: binary");
}
+
// deliver part content
if ($ctype_primary == 'text' && $ctype_secondary == 'html' && empty($plugin['download'])) {
// Check if we have enough memory to handle the message in it
@@ -357,8 +344,7 @@ else if (strlen($part_id)) {
header("Content-Length: $size");
}
- // 8th argument disables re-formatting of text/* parts (#1489267)
- $sent = $RCMAIL->storage->get_message_part($MESSAGE->uid, $part->mime_id, $part, true, null, false, 0, false);
+ $sent = $RCMAIL->storage->get_message_part($MESSAGE->uid, $part->mime_id, $part, true);
}
}
@@ -392,9 +378,7 @@ else {
header('HTTP/1.1 404 Not Found');
exit;
-/**
- * Handles nicely storage connection errors
- */
+
function check_storage_status()
{
$error = rcmail::get_instance()->storage->get_error_code();
@@ -426,49 +410,3 @@ function check_storage_status()
exit;
}
}
-
-/**
- * Attachment properties table
- */
-function rcmail_message_part_controls($attrib)
-{
- global $MESSAGE, $RCMAIL;
-
- $part = asciiwords(get_input_value('_part', RCUBE_INPUT_GPC));
- if (!is_object($MESSAGE) || !is_array($MESSAGE->parts)
- || !($_GET['_uid'] && $_GET['_part']) || !$MESSAGE->mime_parts[$part]
- ) {
- return '';
- }
-
- $part = $MESSAGE->mime_parts[$part];
- $table = new html_table(array('cols' => 2));
-
- $table->add('title', Q(rcube_label('namex')).':');
- $table->add('header', Q(rcmail_attachment_name($part)));
-
- $table->add('title', Q(rcube_label('type')).':');
- $table->add('header', Q($part->mimetype));
-
- $table->add('title', Q(rcube_label('size')).':');
- $table->add('header', Q($RCMAIL->message_part_size($part)));
-
- return $table->show($attrib);
-}
-
-/**
- * Attachment preview frame
- */
-function rcmail_message_part_frame($attrib)
-{
- global $MESSAGE, $RCMAIL;
-
- $part = $MESSAGE->mime_parts[asciiwords(get_input_value('_part', RCUBE_INPUT_GPC))];
- $ctype_primary = strtolower($part->ctype_primary);
-
- $attrib['src'] = './?' . str_replace('_frame=', ($ctype_primary=='text' ? '_embed=' : '_preload='), $_SERVER['QUERY_STRING']);
-
- $RCMAIL->output->add_gui_object('messagepartframe', $attrib['id']);
-
- return html::iframe($attrib);
-}