Matthew Barnes 4f22dc
diff -up evolution-data-server-2.23.4/addressbook/backends/ldap/e-book-backend-ldap.c.fix-ldap-query evolution-data-server-2.23.4/addressbook/backends/ldap/e-book-backend-ldap.c
Matthew Barnes 4f22dc
--- evolution-data-server-2.23.4/addressbook/backends/ldap/e-book-backend-ldap.c.fix-ldap-query	2008-06-15 23:18:08.000000000 -0400
Matthew Barnes 4f22dc
+++ evolution-data-server-2.23.4/addressbook/backends/ldap/e-book-backend-ldap.c	2008-06-16 10:34:29.000000000 -0400
Matthew Barnes 8f1840
@@ -3417,22 +3417,28 @@ func_and(struct _ESExp *f, gint argc, str
Matthew Barnes 8f1840
 	gchar ** strings;
Matthew Barnes 66f626
 
Matthew Barnes 66f626
 	if (argc > 0) {
Matthew Barnes 8f1840
-		gint i;
Matthew Barnes 8f1840
+		gint i, empty;
Matthew Barnes 66f626
 
Matthew Barnes 8f1840
 		strings = g_new0(gchar *, argc+3);
Matthew Barnes 66f626
 		strings[0] = g_strdup ("(&";;
Matthew Barnes 66f626
 		strings[argc+3 - 2] = g_strdup (")");
Matthew Barnes 058223
 
Matthew Barnes 66f626
+		empty = 0;
Matthew Barnes 66f626
 		for (i = 0; i < argc; i ++) {
Matthew Barnes 66f626
 			GList *list_head = ldap_data->list;
Matthew Barnes 66f626
 			if (!list_head)
Matthew Barnes 66f626
 				break;
Matthew Barnes 66f626
+			if (strlen (list_head->data) == 0)
Matthew Barnes 66f626
+				empty++;
Matthew Barnes 66f626
 			strings[argc - i] = list_head->data;
Matthew Barnes 66f626
 			ldap_data->list = g_list_remove_link(list_head, list_head);
Matthew Barnes 66f626
 			g_list_free_1(list_head);
Matthew Barnes 66f626
 		}
Matthew Barnes 66f626
 
Matthew Barnes 66f626
-		ldap_data->list = g_list_prepend(ldap_data->list, g_strjoinv(" ", strings));
Matthew Barnes 66f626
+		if (empty == argc)
Matthew Barnes 66f626
+			ldap_data->list = g_list_prepend(ldap_data->list, g_strdup(" "));
Matthew Barnes 66f626
+		else
Matthew Barnes 66f626
+			ldap_data->list = g_list_prepend(ldap_data->list, g_strjoinv(" ", strings));
Matthew Barnes 66f626
 
Matthew Barnes 8f1840
 		for (i = 0; i < argc + 2; i ++)
Matthew Barnes 66f626
 			g_free (strings[i]);
Matthew Barnes 8f1840
@@ -3454,22 +3460,28 @@ func_or(struct _ESExp *f, gint argc, stru
Matthew Barnes 8f1840
 	gchar ** strings;
Matthew Barnes 66f626
 
Matthew Barnes 66f626
 	if (argc > 0) {
Matthew Barnes 8f1840
-		gint i;
Matthew Barnes 8f1840
+		gint i, empty;
Matthew Barnes 66f626
 
Matthew Barnes 8f1840
 		strings = g_new0(gchar *, argc+3);
Matthew Barnes 66f626
 		strings[0] = g_strdup ("(|");
Matthew Barnes 66f626
 		strings[argc+3 - 2] = g_strdup (")");
Matthew Barnes 66f626
 
Matthew Barnes 66f626
+		empty = 0;
Matthew Barnes 66f626
 		for (i = 0; i < argc; i ++) {
Matthew Barnes 66f626
 			GList *list_head = ldap_data->list;
Matthew Barnes 66f626
 			if (!list_head)
Matthew Barnes 66f626
 				break;
Matthew Barnes 66f626
+			if (strlen (list_head->data) == 0)
Matthew Barnes 66f626
+				empty++;
Matthew Barnes 66f626
 			strings[argc - i] = list_head->data;
Matthew Barnes 66f626
 			ldap_data->list = g_list_remove_link(list_head, list_head);
Matthew Barnes 66f626
 			g_list_free_1(list_head);
Matthew Barnes 66f626
 		}
Matthew Barnes 66f626
 
Matthew Barnes 66f626
-		ldap_data->list = g_list_prepend(ldap_data->list, g_strjoinv(" ", strings));
Matthew Barnes 66f626
+		if (empty == argc)
Matthew Barnes 66f626
+			ldap_data->list = g_list_prepend(ldap_data->list, g_strdup(" "));
Matthew Barnes 66f626
+		else
Matthew Barnes 66f626
+			ldap_data->list = g_list_prepend(ldap_data->list, g_strjoinv(" ", strings));
Matthew Barnes 66f626
 
Matthew Barnes 8f1840
 		for (i = 0; i < argc + 2; i ++)
Matthew Barnes 66f626
 			g_free (strings[i]);
Matthew Barnes 4f22dc
@@ -3622,6 +3634,7 @@ func_beginswith(struct _ESExp *f, int ar
Matthew Barnes 66f626
 		if (strlen (str) == 0) {
Matthew Barnes 4f22dc
 			g_free (str);
Matthew Barnes 4f22dc
 
Matthew Barnes 4f22dc
+			ldap_data->list = g_list_prepend (ldap_data->list, g_strdup (""));
Matthew Barnes 66f626
 			r = e_sexp_result_new (f, ESEXP_RES_BOOL);
Matthew Barnes 66f626
 			r->value.bool = FALSE;
Matthew Barnes 66f626
 			return r;