diff --git a/CHANGELOG b/CHANGELOG index a9bc86dc0..09d1b3366 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,7 @@ CHANGELOG Roundcube Webmail - Add support for SameSite cookie attribute via session_samesite option (req PHP >= 7.3.0) (#6772) - Elastic: Display a special icon for other users and shared namespace roots (#5012) - Change folders sorting so shared/other users namespaces are listed last (#5012) +- Display a warning and do not try to open empty attachments (#7332) - Templates: Add support for expressions in object attributes (#7237) - Templates: Add support for nested if conditions (#6818) - Templates: Make [space][slash] ending of condition objects optional (#6954) diff --git a/program/localization/en_US/messages.inc b/program/localization/en_US/messages.inc index c5ffd54b2..5a4e90bb3 100644 --- a/program/localization/en_US/messages.inc +++ b/program/localization/en_US/messages.inc @@ -223,3 +223,4 @@ $messages['responseinserted'] = 'Response inserted successfully.'; $messages['listempty'] = 'The list is empty.'; $messages['listusebutton'] = 'Use the Create button to add a new record.'; $messages['keypaircreatesuccess'] = 'A new key pair has been successfully created for $identity.'; +$messages['emptyattachment'] = 'This attachment appears to be empty.
Please, check with the person who sent this.'; diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc index 546758a00..759e7c008 100644 --- a/program/steps/mail/show.inc +++ b/program/steps/mail/show.inc @@ -209,20 +209,30 @@ function rcmail_message_attachments($attrib) $item = html::span('attachment-name', rcube::Q($filename)) . html::span('attachment-size', '(' . rcube::Q($filesize) . ')'); + $li_class = $class; + if (!$PRINT_MODE) { - $item = html::a(array( + $link_attrs = array( 'href' => $MESSAGE->get_part_url($attach_prop->mime_id, false), 'onclick' => sprintf('return %s.command(\'load-attachment\',\'%s\',this)', rcmail_output::JS_OBJECT_NAME, $attach_prop->mime_id), 'onmouseover' => $title ? '' : 'rcube_webmail.long_subject_title_ex(this, 0)', 'title' => $title, 'class' => 'filename', - ), $item); + ); + + if ($filesize == 0) { + $li_class .= ' no-menu'; + $link_attrs['onclick'] = sprintf('%s.alert_dialog(%s.get_label(\'emptyattachment\')); return false', + rcmail_output::JS_OBJECT_NAME, rcmail_output::JS_OBJECT_NAME); + $RCMAIL->output->add_label('emptyattachment'); + } + $item = html::a($link_attrs, $item); $attachments[$attach_prop->mime_id] = $mimetype; } - $ol .= html::tag('li', array('class' => $class, 'id' => $id), $item); + $ol .= html::tag('li', array('class' => $li_class, 'id' => $id), $item); } $out = html::tag('ul', $attrib, $ol, html::$common_attrib); diff --git a/skins/classic/functions.js b/skins/classic/functions.js index 99dd4aa25..1b5bed403 100644 --- a/skins/classic/functions.js +++ b/skins/classic/functions.js @@ -1013,6 +1013,9 @@ function percent_indicator(obj, data) function attachment_menu_append(item) { + if ($(item).is('.no-menu')) + return; + $(item).append( $('').on('click keypress', function(e) { if (e.type != 'keypress' || e.which == 13) { diff --git a/skins/larry/ui.js b/skins/larry/ui.js index 2b68ebe97..fbf7c8d51 100644 --- a/skins/larry/ui.js +++ b/skins/larry/ui.js @@ -905,7 +905,7 @@ function rcube_mail_ui() { item = $(item); - if (!item.children('.drop').length) { + if (!item.children('.drop').length && !item.is('.no-menu')) { var label = rcmail.gettext('options'), fname = item.find('a.filename'), tabindex = fname.attr('tabindex') || 0;