From 72ff9f3dd5a526413d2517476a6bf0a0025d4d9a Mon Sep 17 00:00:00 2001 From: Pablo Zmdl Date: Thu, 6 Jun 2024 10:32:42 +0200 Subject: [PATCH] Rename method to more specific name With this meaning we also get rid of the negation in the calling code. --- program/actions/mail/show.php | 4 ++-- program/lib/Roundcube/rcube_message.php | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/program/actions/mail/show.php b/program/actions/mail/show.php index 730f67c101b..a2105e5bc42 100644 --- a/program/actions/mail/show.php +++ b/program/actions/mail/show.php @@ -204,7 +204,7 @@ public static function message_attachments($attrib) } // Skip inline images - if (strpos($mimetype, 'image/') === 0 && !self::$MESSAGE->is_standalone_attachment($attach_prop)) { + if (strpos($mimetype, 'image/') === 0 && self::$MESSAGE->is_referred_attachment($attach_prop)) { continue; } @@ -745,7 +745,7 @@ public static function message_body($attrib) // Content-Type: image/*... if ($mimetype = self::part_image_type($attach_prop)) { // Skip inline images - if (!self::$MESSAGE->is_standalone_attachment($attach_prop)) { + if (self::$MESSAGE->is_referred_attachment($attach_prop)) { continue; } diff --git a/program/lib/Roundcube/rcube_message.php b/program/lib/Roundcube/rcube_message.php index bba4182ae3c..15a432f33f0 100644 --- a/program/lib/Roundcube/rcube_message.php +++ b/program/lib/Roundcube/rcube_message.php @@ -595,17 +595,17 @@ protected function get_replacement_references(): array } /** - * Checks if a given message part is a "standalone" attachment, which means - * that our code is responsible to show it (either in/after the message - * body or as downloadable file). - * Technically this is determined by checking if the part is referenced in - * any HTML-part of the message. + * Checks if a given message part is referred to from another message part. + * Usually this happens if an HTML-part includes images to show inline, but + * technically there can be other cases, too. + * In any case, an attachment that is *not* referred to, shall be shown to + * the users (either in/after the message body or as downloadable file). * * @param rcube_message_part $part Message part * * @return bool True if the part is an attachment part */ - public function is_standalone_attachment(rcube_message_part $part): bool + public function is_referred_attachment(rcube_message_part $part): bool { $references = $this->get_replacement_references(); @@ -613,16 +613,16 @@ public function is_standalone_attachment(rcube_message_part $part): bool // Filter out attachments that are reference by their Content-ID in // another mime-part. if (!empty($part->content_id) && in_array($part->content_id, $references)) { - return false; + return true; } // Filter out attachments that are reference by their // Content-Location in another mime-part. if (!empty($part->content_location) && in_array($part->content_location, $references)) { - return false; + return true; } - return true; + return false; } /**