Skip to content

Commit

Permalink
Rename method to more specific name
Browse files Browse the repository at this point in the history
With this meaning we also get rid of the negation in the calling code.
  • Loading branch information
pabzm committed Jun 6, 2024
1 parent 614fff4 commit 72ff9f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions program/actions/mail/show.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
18 changes: 9 additions & 9 deletions program/lib/Roundcube/rcube_message.php
Original file line number Diff line number Diff line change
Expand Up @@ -595,34 +595,34 @@ 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();

// This code is intentionally verbose to keep it comprehensible.
// 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;
}

/**
Expand Down

0 comments on commit 72ff9f3

Please sign in to comment.