From f2b5ff4623c8f9b724e3f13db7055f5df575db8b Mon Sep 17 00:00:00 2001 From: Sivaiah Nallagatla Date: Wed, 17 Nov 2004 20:57:34 +0000 Subject: When name is NULL query against complete email id instead of user name 2004-11-07 Sivaiah Nallagatla * util/eab-book-util.c (eab_name_and_email_query) : When name is NULL query against complete email id instead of user name part to take care of users@foo.org not matching against users@bar.org . Also include query based on name always Fix for #67656 svn path=/trunk/; revision=27937 --- addressbook/ChangeLog | 10 ++++++++++ addressbook/util/eab-book-util.c | 13 ++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index fefd3125da..013aa4e363 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,13 @@ +2004-11-07 Sivaiah Nallagatla + + * util/eab-book-util.c (eab_name_and_email_query) : + When name is NULL query against complete email id instead of + user name part to take care of users@foo.org not matching + against users@bar.org . Also include query based on name always + + Fix for #67656 + + 2004-11-08 Andre Klapper Fixes bug #61966. diff --git a/addressbook/util/eab-book-util.c b/addressbook/util/eab-book-util.c index 1fdcd59ca0..4978fa7b59 100644 --- a/addressbook/util/eab-book-util.c +++ b/addressbook/util/eab-book-util.c @@ -100,12 +100,14 @@ eab_name_and_email_query (EBook *book, * We only query against the username part of the address, to avoid not matching * fred@foo.com and fred@mail.foo.com. While their may be namespace collisions * in the usernames of everyone out there, it shouldn't be that bad. (Famous last words.) + * But if name is missing we query against complete email id to avoid matching emails like + * users@foo.org with users@bar.org */ if (escaped_email) { const gchar *t = escaped_email; while (*t && *t != '@') ++t; - if (*t == '@') { + if (*t == '@' && escaped_name) { email_query = g_strdup_printf ("(beginswith \"email\" \"%.*s@\")", t-escaped_email, escaped_email); } else { @@ -113,12 +115,9 @@ eab_name_and_email_query (EBook *book, } } - /* Build our name query. - * We only do name-query stuff if we don't have an e-mail address. Our basic assumption - * is that the username part of the email is good enough to keep the amount of stuff returned - * in the query relatively small. - */ - if (escaped_name && !escaped_email) + /* Build our name query.*/ + + if (escaped_name) name_query = g_strdup_printf ("(or (beginswith \"file_as\" \"%s\") (beginswith \"full_name\" \"%s\"))", escaped_name, escaped_name); /* Assemble our e-mail & name queries */ -- cgit