summaryrefslogtreecommitdiff
path: root/roundcubemail/program/steps/mail/get.inc
diff options
context:
space:
mode:
authoralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2011-11-25 13:47:07 +0000
committeralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2011-11-25 13:47:07 +0000
commit28a60f6bee5ecbec21e4bb4ed74750c42e7f1975 (patch)
treebad3eaa9099e500a373e1560d0e228bce332b473 /roundcubemail/program/steps/mail/get.inc
parent8a80c1b0c69d04d2b73e2b6543dd259ecd09f370 (diff)
- Prevent from memory_limit exceeding when trying to parse big messages bodies (#1487424):
don't try to parse it, display notice with a link to download it directly git-svn-id: https://svn.roundcube.net/trunk@5490 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/steps/mail/get.inc')
-rw-r--r--roundcubemail/program/steps/mail/get.inc24
1 files changed, 18 insertions, 6 deletions
diff --git a/roundcubemail/program/steps/mail/get.inc b/roundcubemail/program/steps/mail/get.inc
index 828f8debc..a0ea3e163 100644
--- a/roundcubemail/program/steps/mail/get.inc
+++ b/roundcubemail/program/steps/mail/get.inc
@@ -70,7 +70,7 @@ if (!empty($_GET['_frame'])) {
exit;
}
-else if ($pid = get_input_value('_part', RCUBE_INPUT_GET)) {
+else if (strlen($pid = get_input_value('_part', RCUBE_INPUT_GET))) {
if ($part = $MESSAGE->mime_parts[$pid]) {
$ctype_primary = strtolower($part->ctype_primary);
@@ -109,18 +109,30 @@ else if ($pid = get_input_value('_part', RCUBE_INPUT_GET)) {
// deliver part content
if ($ctype_primary == 'text' && $ctype_secondary == 'html' && empty($plugin['download'])) {
- // get part body if not available
- if (!$part->body)
- $part->body = $MESSAGE->get_part_content($part->mime_id);
+ // Check if we have enough memory to handle the message in it
+ // #1487424: we need up to 10x more memory than the body
+ if (!rcmail_mem_check($part->size * 10)) {
+ $out = '<body>' . rcube_label('messagetoobig'). ' '
+ . html::a('?_task=mail&_action=get&_download=1&_uid='.$MESSAGE->uid.'&_part='.$part->mime_id
+ .'&_mbox='. urlencode($IMAP->get_mailbox_name()), rcube_label('download')) . '</body></html>';
+ }
+ else {
+ // get part body if not available
+ if (!$part->body)
+ $part->body = $MESSAGE->get_part_content($part->mime_id);
+
+ $out = rcmail_print_body($part, array('safe' => $MESSAGE->is_safe, 'inline_html' => false));
+ }
$OUTPUT = new rcube_html_page();
- $OUTPUT->write(rcmail_print_body($part, array('safe' => $MESSAGE->is_safe, 'inline_html' => false)));
+ $OUTPUT->write($out);
}
else {
// don't kill the connection if download takes more than 30 sec.
@set_time_limit(0);
- $filename = $part->filename ? $part->filename : ($MESSAGE->subject ? $MESSAGE->subject : 'roundcube') . '.'.$ctype_secondary;
+ $ext = '.' . ($mimetype == 'text/plain' ? 'txt' : $ctype_secondary);
+ $filename = $part->filename ? $part->filename : ($MESSAGE->subject ? $MESSAGE->subject : 'roundcube') . $ext;
$filename = preg_replace('[\r\n]', '', $filename);
if ($browser->ie && $browser->ver < 7)