Fix so max_message_size limit is checked also when forwarding messages as attachments (#6580)

pull/6591/head
Aleksander Machniak 5 years ago
parent d7b510978e
commit e69d1e7f04

@ -40,6 +40,7 @@ CHANGELOG Roundcube Webmail
- Elastic: Fix unwanted thread expanding when selecting a collapsed thread in non-mobile mode (#6445)
- Elastic: Add "status bar" for mobile in mail composer
- Log errors caused by low pcre.backtrack_limit when sending a mail message (#6433)
- Fix so max_message_size limit is checked also when forwarding messages as attachments (#6580)
- Fix so performance stats are logged to the main console log also when per_user_logging=true
- Fix malformed message saved into Sent folder when using big attachments and low memory limit (#6498)
- Fix incorrect IMAP SASL GSSAPI negotiation (#6308)

@ -1706,7 +1706,7 @@ EOF;
* Add inline javascript code
*
* @param string $script JS code snippet
* @param string $position Target position [head|head_top|foot]
* @param string $position Target position [head|head_top|foot|docready]
*/
public function add_script($script, $position = 'head')
{

@ -129,6 +129,7 @@ $messages['fileuploaderror'] = 'File upload failed.';
$messages['filesizeerror'] = 'The uploaded file exceeds the maximum size of $size.';
$messages['filecounterror'] = 'You can upload maximum $count files at once.';
$messages['msgsizeerror'] = 'Failed to attach a file. Maximum size of a message ($size) exceeded.';
$messages['msgsizeerrorfwd'] = 'Maximum size of a message ($size) exceeded. $num message(s) have not been attached.';
$messages['copysuccess'] = 'Successfully copied $nr contacts.';
$messages['movesuccess'] = 'Successfully moved $nr contacts.';
$messages['copyerror'] = 'Could not copy any contacts.';

@ -1033,17 +1033,21 @@ function rcmail_write_forward_attachments()
{
global $RCMAIL, $COMPOSE, $MESSAGE;
$storage = $RCMAIL->get_storage();
$names = array();
$refs = array();
if ($MESSAGE->pgp_mime) {
return;
}
$storage = $RCMAIL->get_storage();
$names = array();
$refs = array();
$size_errors = 0;
$size_limit = parse_bytes($RCMAIL->config->get('max_message_size'));
$total_size = 10 * 1024; // size of message body, to start with
$loaded_attachments = array();
foreach ((array)$COMPOSE['attachments'] as $attachment) {
$loaded_attachments[$attachment['name'] . $attachment['mimetype']] = $attachment;
$total_size += $attachment['size'];
}
if ($COMPOSE['forward_uid'] == '*') {
@ -1085,6 +1089,13 @@ function rcmail_write_forward_attachments()
continue;
}
if ($size_limit && $size_limit < $total_size + $message->headers->size) {
$size_errors++;
continue;
}
$total_size += $message->headers->size;
rcmail_save_attachment($message, null, $COMPOSE['id'], array('filename' => $name));
if ($message->headers->messageID) {
@ -1096,9 +1107,16 @@ function rcmail_write_forward_attachments()
if (count($refs) == 1) {
$COMPOSE['reply_msgid'] = $refs[0];
}
if (!empty($refs)) {
$COMPOSE['references'] = implode(' ', $refs);
}
if ($size_errors) {
$limit = $RCMAIL->show_bytes($size_limit);
$error = $RCMAIL->gettext(array('name' => 'msgsizeerrorfwd', 'vars' => array('num' => $size_errors, 'size' => $limit)));
$RCMAIL->output->add_script(sprintf("%s.display_message('%s', 'error');", rcmail_output::JS_OBJECT_NAME, rcube::JQ($error)), 'docready');
}
}
// Saves an image as attachment

Loading…
Cancel
Save