After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 304029 - Highly Ineffective LDAP filters
Highly Ineffective LDAP filters
Status: RESOLVED FIXED
Product: evolution
Classification: Applications
Component: Contacts
2.2.x (obsolete)
Other Linux
: Normal normal
: ---
Assigned To: evolution-addressbook-maintainers
Evolution QA team
Depends on:
Blocks: 327508 327510
 
 
Reported: 2005-05-13 10:45 UTC by Sebastien Bacher
Modified: 2013-09-10 14:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed patch (3.75 KB, patch)
2007-05-18 11:05 UTC, Milan Crha
none Details | Review
evolution part of proposed patch (1.51 KB, patch)
2007-05-22 13:48 UTC, Milan Crha
committed Details | Review
e-d-s part of proposed patch (8.19 KB, patch)
2007-05-22 13:58 UTC, Milan Crha
needs-work Details | Review
proposed eds patch (7.58 KB, patch)
2007-08-29 08:16 UTC, Milan Crha
committed Details | Review

Description Sebastien Bacher 2005-05-13 10:45:08 UTC
This bug has been opened here: https://bugzilla.ubuntu.com/10629

"The LDAP search filters generated by evolution to search for addresses in the
directory are "highly ineffective" at finding people.
Here is an example of looking for a person named Kelly Smith (cn: Kelly E Smith).

# from our logs
# lets find everyone named exactly kelly smith.*, of course the person is named
Kelly E Smith, but I don't know his middle initial
# in this case the user is not found, and I become so frustrated that I do the
search using the command line ldap tool
May 11 08:51:37 peregrine slapd[15549]: conn=298480 op=41 SRCH base="o=CSUN"
scope=2 deref=0 filter="(&(objectClass=person)(|(sn=kelly smith*)(|(cn=kelly
smith*)(sn=kelly smith*))(mail=kelly smith*)(displayName=kelly smith*)))"

# here is an example of thunderbird doing a similar search for a user named
Caleb Fahey (cn: Caleb N Fahey)
# in this case the user is found on the first try, evolution would not have
found this user unless I had known his middle initial.
May 11 09:19:02 peregrine slapd[15549]: conn=300736 op=1 SRCH base="o=csun"
scope=2 deref=0 filter="(|(cn=caleb*fa*)(mail=caleb*fa*)(sn=caleb*fa*))"

In order to interoperate with organizations which store middle initials in the
cn, it is suggested that the "any" component of the substring filter (as
documented in rfc2251) be set to the last token in either the search field or
the autocomplete feild."
Comment 1 Milan Crha 2007-05-18 11:05:02 UTC
Created attachment 88380 [details] [review]
proposed patch

for evolution-data-server
Comment 2 Milan Crha 2007-05-18 11:20:36 UTC
Please try this patch. I'm not sure if it will work fine with whole evolution, this patch only changes ldap search string generation, where are added stars in place of the first space (of consecutive spaces) between words. So the search string may be now same as from Thunderbird. Because it changes only first space in a space-sequence, then one could easily use spaces in filters and filter on more words. (I mean, put string "Mil  C" will create ldap search value "Mil* C*" (for 'starts with'), so ldap will search for two words separated by a space.)

As I tested this, then if you have cn like "Milan Crha" and you will search for 'starts with' "Mil Cr", then resulting filter value in ldap will be "Mil*Cr*", which _will_ return correct result in ldap, but this name isn't displayed in Evolution (it's filtered somewhere else, not in ldap).
Comment 3 Milan Crha 2007-05-18 13:35:39 UTC
I did look there, and it needs to change in evolution-data-server/addressbook/libedtata-book/e-book-backend-sexp.c those helper functions for comparing strings thus they will work with spaces in same way like in the patch from comment #1. Because this is such a big work, it will need an approval from evolution developer(s).
Comment 4 Ross Burton 2007-05-21 15:04:49 UTC
I think the correct way to solve this would be:

1) when a full_name contains search is done, add wildcards between each word.
2) Change Evolution so that the default contact search is "fullname contains" not "fullname startswith", which isn't really that intuitive when middle names are stored in the addressbook.
Comment 5 Milan Crha 2007-05-22 13:28:53 UTC
ad 2) Maybe we need to change that same thing when autocompleting email address when composing new mail, what do you think Ross?
Comment 6 Milan Crha 2007-05-22 13:48:59 UTC
Created attachment 88608 [details] [review]
evolution part of proposed patch

for evolution;

only changes description and filter string of default filter "Name begins with" on "Name contains". Because of that description change, it may need to translate properly (but I'm not sure with this.)
Comment 7 Milan Crha 2007-05-22 13:58:16 UTC
Created attachment 88609 [details] [review]
e-d-s part of proposed patch

for evolution-data-server;

it's a bit longer, I added a few helper functions there, but I hope it will be fine. It only separate filter string into words and then recursively searches for these words, instead of searching for all words like it is one.
I also improved an endswith function, so it works well with prefixes. (I mean, with name "Ross", when you will look for endswith "s" then old search will not work properly, this one will).
Comment 8 Srinivasa Ragavan 2007-05-28 16:00:30 UTC
Ross, can you review it for 2.11.3?
Comment 9 Srinivasa Ragavan 2007-06-30 20:05:59 UTC
Ross: poke
Comment 10 Srinivasa Ragavan 2007-08-10 10:28:20 UTC
Ross: for 2.11.90?
Comment 11 Ross Burton 2007-08-28 14:34:05 UTC
Comment on attachment 88609 [details] [review]
e-d-s part of proposed patch

endswith_helper() in -sexp.c is very slow and should be able to be rewritten as a string comparison, something like e_util_utf8_strstrcase (s1 + strlen (s1) - strlen (s2), s2).
Comment 12 Milan Crha 2007-08-29 08:16:14 UTC
Created attachment 94539 [details] [review]
proposed eds patch

for evolution-data-server;

you've right, ross, here is an improved patch. God knows why I did it such complicated...
Comment 13 Milan Crha 2008-01-04 16:23:47 UTC
ping ross, can you review this, please?
Comment 14 André Klapper 2008-04-26 21:27:19 UTC
ross: ping.
Comment 15 Milan Crha 2008-06-12 07:50:28 UTC
Ross, ping again, this took awfully long time, and it's not so hard, can you review please?
Comment 16 Ross Burton 2008-06-13 09:16:32 UTC
Hmm.  Well, I'm not entirely convinced that this is the best solution, but it should work.
Comment 17 Milan Crha 2008-06-13 09:48:56 UTC
eds part committed to trunk. Committed revision 8979.
evo part committed to trunk. Committed revision 35635.