Ticket #1485581 (closed Bugs: fixed)

Opened 6 weeks ago

Last modified 6 weeks ago

Search stopped working

Reported by: rosali Owned by:
Priority: 5 Milestone: 0.2-stable
Component: IMAP connection Version: 0.2-beta
Severity: normal Keywords: Search
Cc:

Description

Steps to reprocude:

1. Do not specify a header in the search box

2. ./program/steps/mail/search.inc ...

$search_str (for query "test") results in ...

OR (HEADER SUBJECT {4} test) (HEADER FROM {4} test)

3. hMailServer returns all messages ...

Search requests by specifying a header works (e.g. subject:test)

Attachments

console (37.1 kB) - added by rosali 6 weeks ago.
console

Change History

follow-up: ↓ 2   Changed 6 weeks ago by alec

  • component changed from Client Scripts to IMAP connection

Maybe hMailServer does not support OR in SEARCH. Before my changes in searching two separate search calls were used. Now OR is used. Can you check IMAP conversation (uncomment console in lib/imap.inc)?

in reply to: ↑ 1   Changed 6 weeks ago by rosali

Replying to alec:

Maybe hMailServer does not support OR in SEARCH. Before my changes in searching two separate search calls were used. Now OR is used. Can you check IMAP conversation (uncomment console in lib/imap.inc)?

I did some debugging:

hMailServer does not like the round brackets "(" ...

this works:

search.inc line 83:

$search_str .= sprintf(" %s {%d}\r\n%s", $sub, strlen($search), $search);

I'm not familiar with this RFC stuff! Is it a hMailServer bug?

Changed 6 weeks ago by rosali

console

  Changed 6 weeks ago by alec

RFC3501: "When multiple keys are specified, the result is the intersection

(AND function) of all the messages that match those keys. For example, the criteria DELETED FROM "SMITH" SINCE 1-Feb-1994 refers to all deleted messages from Smith that were placed in the mailbox since February 1, 1994. A search key can also be a parenthesized list of one or more search keys (e.g., for use with the OR and NOT keys)."

Please try also "SORT (DATE) ALL (OR (HEADER SUBJECT c) (HEADER FROM c))

follow-up: ↓ 5   Changed 6 weeks ago by rosali

hMailServer log:

SORT (DATE) UTF-8 ALL (OR (HEADER SUBJECT c) (HEADER FROM c))

--> returns all messages also!

in reply to: ↑ 4   Changed 6 weeks ago by rosali

hMailServer log: SORT (DATE) UTF-8 ALL (OR (HEADER SUBJECT {4} test) (HEADER FROM {4} test))

--> returns all messages also!

If it is just a hMailServer bug, please confirm and close the ticket. It is not a problem for me to hijack the step file only for hMailServer backends by my plugin API.

  Changed 6 weeks ago by alec

What hMailServer version? You should ask on hMailServer's forum, it's developers should confirm the issue or maybe it was fixed.

  Changed 6 weeks ago by rosali

So, in your opinion it is a bug?

I have tested both: hMailServer latest stable 4.x and hMailServer beta 5.x.

Just confirm if it is an hmail bug in you opinion and close ticket! Thnx

follow-up: ↓ 9   Changed 6 weeks ago by alec

So, in my opinion it's a bug in hmailserver. In addition, when we remove parenthesses it stops working with dovecot. Not closing now, maybe we should add a workaround for hmailserver.

in reply to: ↑ 8   Changed 6 weeks ago by rosali

Replying to alec:

So, in my opinion it's a bug in hmailserver. In addition, when we remove parenthesses it stops working with dovecot. Not closing now, maybe we should add a workaround for hmailserver.

... done ... Thnx!

http://hmailserver.com/forum/viewtopic.php?f=7&t=13518

  Changed 6 weeks ago by knafve

Alec,

I'm working on fixing the issue on the hMailServer side. As far as I can tell, the paranthesises hold no real significant. The paranthesises can be stripped out of a SEARCH/SORT command without affecting the expected result. Can you confirm that I'm right on that?

For example: (Criteria1 OR (Criteria2 Criteria 3) has the same meaning as (Criteria1 OR Criteria2 Criteria 3

(As I read the RFC, the paranthesises are optional so it would appear that dovecot isn't working properly either)

  Changed 6 weeks ago by alec

  • status changed from new to closed
  • resolution set to fixed

I'm not a guru and my english is not perfect, but RFC3501 (6.4.4) says "When multiple keys are specified, the result is the intersection (AND function) of all the messages that match those keys" and "A search key can also be a parenthesized list of one or more search keys (e.g., for use with the OR and NOT keys)", but wait... I've made some tests again with dovecot and looks like it's working with all cases as follows:

SORT (DATE) UTF-8 ALL UNANSWERED OR HEADER SUBJECT aa HEADER FROM aa
SORT (DATE) UTF-8 ALL UNANSWERED OR (HEADER SUBJECT aa) (HEADER FROM aa)
SORT (DATE) UTF-8 ALL UNANSWERED (OR HEADER SUBJECT aa HEADER FROM aa)

Fixed in r2091. By the way, is it possible to OR'ing more than 2 search keys?

  Changed 6 weeks ago by knafve

The RFC's are tricky to read sometimes regardless of how good you are at English. =)

The next build of hMailServer will work with the three examples you just posted. The three examples will be interpreted in the exact same way.

It's not possible to OR more than 2 search keys as far as I know, but you can create combinations of multiple OR's, such as

OR OR HEADER SUBJECT a HEADER SUBJECT b HEADER SUBJECT c

You can create really terrible search expressions this way, similar to

OR OR OR NOT OR OR OR ON 28-May-2008 ON 28-May-2008 ON 28-May-2008 ON 28-May-2008 ON 28-May-2008 ON 28-May-2008 ON 28-May-2008 ALL

Note: See TracTickets for help on using tickets.