Skip to content

Advanced search syntax (no UI) "has:attachment" doesn't use the $HasAttachment keyword #10168

Description

@gurnec

Prerequisites

  • I have searched for duplicate or closed issues
  • I can recreate the issue with all plugins disabled

Describe the issue

Typing "has:attachment" in the search field can return different results than using the Type: With attachment UI filter. The latter uses the $HasAttachment/$HasNoAttachment keywords and produced better results (depending on IMAP server config) versus the former.

$HasAttachment used:

$ctypes = ['application/', 'multipart/mixed', 'multipart/signed', 'multipart/report'];
// Build search string of "with attachment" filter
$attachment = trim(str_repeat(' OR', count($ctypes))) . ' KEYWORD $HasAttachment';
foreach ($ctypes as $type) {
$attachment .= ' HEADER Content-Type ' . rcube_imap_generic::escape($type);
}
$attachment .= ' NOT KEYWORD $HasNoAttachment';

$HasAttachment missing:

$ctypes = ['application/', 'multipart/mixed', 'multipart/signed', 'multipart/report'];
// Build search string of "with attachment" filter
$result = str_repeat(' OR', count($ctypes) - 1);
foreach ($ctypes as $type) {
$result .= ' HEADER Content-Type ' . rcube_imap_generic::escape($type);
}
return trim($result);

What browser(s) are you seeing the problem on?

Chrome

What version of PHP are you using?

v8.3

What version of Roundcube are you using?

v1.7.0

JavaScript errors

No response

PHP errors

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions