[evolution-data-server] Bug #487988 - Bad search filter for LDAP address book



commit 8f6ac8a8af055d4b5e38ec3c599f125b489f0cd3
Author: Alex Larsson <alexl redhat com>
Date:   Thu Dec 3 12:28:21 2009 +0100

    Bug #487988 - Bad search filter for LDAP address book

 addressbook/backends/ldap/e-book-backend-ldap.c |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/addressbook/backends/ldap/e-book-backend-ldap.c b/addressbook/backends/ldap/e-book-backend-ldap.c
index 4eb6e48..a3d1af6 100644
--- a/addressbook/backends/ldap/e-book-backend-ldap.c
+++ b/addressbook/backends/ldap/e-book-backend-ldap.c
@@ -3647,22 +3647,28 @@ func_and(struct _ESExp *f, gint argc, struct _ESExpResult **argv, gpointer data)
 	gchar ** strings;
 
 	if (argc > 0) {
-		gint i;
+		gint i, empty;
 
 		strings = g_new0(gchar *, argc+3);
 		strings[0] = g_strdup ("(&");
 		strings[argc+3 - 2] = g_strdup (")");
 
+		empty = 0;
 		for (i = 0; i < argc; i ++) {
 			GList *list_head = ldap_data->list;
 			if (!list_head)
 				break;
+			if (strlen (list_head->data) == 0)
+				empty++;
 			strings[argc - i] = list_head->data;
 			ldap_data->list = g_list_remove_link(list_head, list_head);
 			g_list_free_1(list_head);
 		}
 
-		ldap_data->list = g_list_prepend(ldap_data->list, g_strjoinv(" ", strings));
+		if (empty == argc)
+			ldap_data->list = g_list_prepend (ldap_data->list, g_strdup (" "));
+		else
+			ldap_data->list = g_list_prepend (ldap_data->list, g_strjoinv (" ", strings));
 
 		for (i = 0; i < argc + 2; i ++)
 			g_free (strings[i]);
@@ -3684,22 +3690,28 @@ func_or(struct _ESExp *f, gint argc, struct _ESExpResult **argv, gpointer data)
 	gchar ** strings;
 
 	if (argc > 0) {
-		gint i;
+		gint i, empty;
 
 		strings = g_new0(gchar *, argc+3);
 		strings[0] = g_strdup ("(|");
 		strings[argc+3 - 2] = g_strdup (")");
 
+		empty = 0;
 		for (i = 0; i < argc; i ++) {
 			GList *list_head = ldap_data->list;
 			if (!list_head)
 				break;
+			if (strlen (list_head->data) == 0)
+				empty++;
 			strings[argc - i] = list_head->data;
 			ldap_data->list = g_list_remove_link(list_head, list_head);
 			g_list_free_1(list_head);
 		}
 
-		ldap_data->list = g_list_prepend(ldap_data->list, g_strjoinv(" ", strings));
+		if (empty == argc)
+			ldap_data->list = g_list_prepend (ldap_data->list, g_strdup (" "));
+		else
+			ldap_data->list = g_list_prepend (ldap_data->list, g_strjoinv (" ", strings));
 
 		for (i = 0; i < argc + 2; i ++)
 			g_free (strings[i]);
@@ -3852,6 +3864,8 @@ func_beginswith(struct _ESExp *f, gint argc, struct _ESExpResult **argv, gpointe
 		if (strlen (str) == 0) {
 			g_free (str);
 
+			ldap_data->list = g_list_prepend (ldap_data->list, g_strdup (""));
+
 			r = e_sexp_result_new (f, ESEXP_RES_BOOL);
 			r->value.bool = FALSE;
 			return r;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]