View Issue Details

IDProjectCategoryView StatusLast Update
0001251SOGoWeb Address Bookpublic2011-06-16 17:13
Reporteresco Assigned Toludovic  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version1.3.6 
Target Version1.3.8Fixed in Version1.3.8 
Summary0001251: Import of exported LDIF don't work with Umlauts
Description

It is not possible to import an exported contact with Umlauts correctly. Every entry containing Umlauts gets removed.

To reproduce this you can use the Online Demo and create an contact with some Umlauts (äöü).

TagsNo tags attached.

Activities

2011-05-06 13:20

 

Christian Mack

Christian Mack

2011-05-06 13:22

developer   ~0002436

Added an Ldif test contact with Umlaut 'ü' in it.

After import you only see email and phone number in your adressbook.

2011-06-08 17:18

 

UIxContactFolderActions.m.diff (3,233 bytes)   
#
# old_revision [64282771e1fb25846e93ccef41b7198b11c569f6]
#
# patch "UI/Contacts/UIxContactFolderActions.m"
#  from [3bb12edeeb0b14570c9a47783005e5c87344b4ca]
#    to [2f74e68bbc80a1bb9fd318484b0ee12c2a31e6dc]
#
============================================================
--- UI/Contacts/UIxContactFolderActions.m	3bb12edeeb0b14570c9a47783005e5c87344b4ca
+++ UI/Contacts/UIxContactFolderActions.m	2f74e68bbc80a1bb9fd318484b0ee12c2a31e6dc
@@ -30,6 +30,7 @@
 #import <NGObjWeb/WORequest.h>
 #import <NGExtensions/NSString+misc.h>
 #import <NGExtensions/NSNull+misc.h>
+#import <NGExtensions/NGBase64Coding.h>
 
 #import <Contacts/SOGoContactObject.h>
 #import <Contacts/SOGoContactFolder.h>
@@ -154,30 +155,69 @@
   for (i = 0; i < count; i++)
     {
       SOGoContactLDIFEntry *ldifEntry;
-      entry = [NSMutableDictionary dictionary];
+      NSEnumerator *keyEnumerator;
+      NSMutableDictionary *encodedEntry;
+      encodedEntry = [NSMutableDictionary dictionary];
       lines = [[ldifContacts objectAtIndex: i] 
                componentsSeparatedByString: @"\n"];
 
+      key = NULL;
       linesCount = [lines count];
       for (j = 0; j < linesCount; j++)
         {
-          components = [[lines objectAtIndex: j] 
-                 componentsSeparatedByString: @": "];
+          NSString *line;
+          line = [lines objectAtIndex: j];
+
+          /* skip embedded comment lines */
+          if ([line hasPrefix: @"#"])
+            {
+              key = NULL;
+              continue;
+            }
+
+          /* handle continuation lines */
+          if ([line hasPrefix: @" "])
+            {
+              if (key != NULL)
+                {
+                  value = [[encodedEntry valueForKey: key]
+                           stringByAppendingString: [line substringFromIndex: 1]];
+                  [encodedEntry setValue: value forKey: key];
+                }
+              continue;
+            }
+
+          components = [line componentsSeparatedByString: @": "];
           if ([components count] == 2)
             {
-              key = [components objectAtIndex: 0];
+              key = [[components objectAtIndex: 0] lowercaseString];
               value = [components objectAtIndex: 1];
 
               if ([key length] == 0)
                 key = @"dn";
 
-              [entry setObject: value forKey: [key lowercaseString]];
+              [encodedEntry setValue: value forKey: key];
             }
           else
             {
               break;
             }
         }
+
+      /* decode Base64-encoded attributes */
+      entry = [NSMutableDictionary dictionary];
+      keyEnumerator = [encodedEntry keyEnumerator];
+      while ((key = [keyEnumerator nextObject]))
+        {
+          value = [encodedEntry valueForKey: key];
+          if ([key hasSuffix: @":"])
+            {
+              key = [key substringToIndex: [key length] - 1];
+              value = [value stringByDecodingBase64];
+            }
+          [entry setValue: value forKey: key];
+        }
+
       uid = [folder globallyUniqueObjectId];
       ldifEntry = [SOGoContactLDIFEntry contactEntryWithName: uid
                                                withLDIFEntry: entry
UIxContactFolderActions.m.diff (3,233 bytes)   
avoegele

avoegele

2011-06-08 17:24

reporter   ~0002547

Names with umlauts aren't imported since the LDIF importer doesn't decode Base64-encoded attributes. I've attached the patch file "UIxContactFolderActions.m.diff" whichs adds decoding of Base64-encoded attributes and handling of continuation lines to the LDIF importer. Tested with the LDIF file attached to this ticket and my Thunderbird addressbook.

ludovic

ludovic

2011-06-16 17:13

administrator   ~0002596

http://mtn.inverse.ca/revision/diff/9b6ca5cb2b17f229443223ae6bb703c37ca1f0c3/with/95fd526cbec8bccb226bbd63d3442c7d12061aa3

Issue History

Date Modified Username Field Change
2011-04-11 11:07 esco New Issue
2011-05-06 13:20 Christian Mack File Added: Persönliches Adressbuch.ldif
2011-05-06 13:22 Christian Mack Note Added: 0002436
2011-06-08 17:18 avoegele File Added: UIxContactFolderActions.m.diff
2011-06-08 17:24 avoegele Note Added: 0002547
2011-06-15 20:18 ludovic Status new => assigned
2011-06-15 20:18 ludovic Assigned To => ludovic
2011-06-15 20:18 ludovic Target Version => 1.3.8
2011-06-16 17:13 ludovic Note Added: 0002596
2011-06-16 17:13 ludovic Status assigned => resolved
2011-06-16 17:13 ludovic Fixed in Version => 1.3.8
2011-06-16 17:13 ludovic Resolution open => fixed