]> git.deb.at Git - pkg/abook.git/commitdiff
ldif: don't dump "email:" if the email field is empty.
authorRaphaël Droz <raphael.droz+floss@gmail.com>
Thu, 13 Dec 2012 16:31:17 +0000 (17:31 +0100)
committerRaphaël Droz <raphael.droz+floss@gmail.com>
Thu, 13 Dec 2012 17:03:09 +0000 (18:03 +0100)
filter.c

index e928492e596ffeddc69d0c8c380a73d8978e97b9..3aa3708a78acd5c2c23b1c8d0450a74821a4b4cb 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -883,16 +883,22 @@ ldif_export_database(FILE *out, struct db_enumerator e)
                int j;
                get_first_email(email, e.item);
 
-               tmp = strdup_printf("cn=%s,mail=%s",db_name_get(e.item),email);
+               if(*email)
+                       tmp = strdup_printf("cn=%s,mail=%s",db_name_get(e.item),email);
+               else
+                       tmp = strdup_printf("cn=%s",db_name_get(e.item));
 
                ldif_fput_type_and_value(out, "dn", tmp);
                free(tmp);
 
                for(j = 0; j < LDIF_ITEM_FIELDS; j++) {
                        if(ldif_conv_table[j] >= 0) {
-                               if(ldif_conv_table[j] == EMAIL)
-                                       ldif_fput_type_and_value(out,
-                                               ldif_field_names[j], email);
+                               if(ldif_conv_table[j] == EMAIL) {
+                                       if(*email) // don't dump en empty email field
+                                               ldif_fput_type_and_value(out,
+                                                                        ldif_field_names[j],
+                                                                        email);
+                               }
                                else if(db_fget(e.item,ldif_conv_table[j]))
                                        ldif_fput_type_and_value(out,
                                                ldif_field_names[j],