grosjo / fts-xapian

Dovecot FTS plugin based on Xapian
GNU Lesser General Public License v2.1
91 stars 19 forks source link

Incorrect XAPIAN_WILDCARD handling #154

Closed mikhailkilyakov closed 4 months ago

mikhailkilyakov commented 5 months ago

Hello

Just investigated strange behavior (commit = a8fa71220b2096be4a6b558ed0c85434ed6994da).

Steps to reproduce:

  1. Index folders

  2. Try to search using BODY, results should be present:

doveadm -Dv search -u user@domain.com BODY 'hello'

  1. Try to search using TEXT, result is empty:

doveadm -Dv search -u user@domain.com TEXT 'hello'

The reason is in sligthly incorrect checking of passed header value (https://github.com/grosjo/fts-xapian/blob/a8fa71220b2096be4a6b558ed0c85434ed6994da/src/fts-backend-xapian-functions.cpp#L148-L156).

The specified code returns from method when no header is found in hdrs_emails. Constant XAPIAN_WILDCARD is not in the list, thus it will never process all headers (however it should when TEXT is passed).

Possible solution:

Replace line 152:

if(i>=HDRS_NB)

With this code:

if((i>=HDRS_NB) && (strcmp(h2, XAPIAN_WILDCARD)!=0))

Thanks

grosjo commented 5 months ago

Indeed. Kindly check latest git

grosjo commented 4 months ago

I tested it. It seems working. If not, kindly reopen the issue