Skip to content

Commit

Permalink
(fix) handle semicolon in value during LDIF import (fixes #1760)
Browse files Browse the repository at this point in the history
  • Loading branch information
extrafu committed Dec 29, 2016
1 parent 6349365 commit e46c51e
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions UI/Contacts/UIxContactFolderActions.m
Expand Up @@ -155,13 +155,16 @@ + (void) initialize

- (int) importLdifData: (NSString *) ldifData
{
NSArray *ldifContacts, *lines, *components;
NSMutableDictionary *entry, *encodedEntry;
SOGoContactLDIFEntry *ldifEntry;
NSArray *ldifContacts, *lines;
SOGoContactGCSFolder *folder;
NSMutableDictionary *entry;
NSString *key, *uid;
NSEnumerator *keyEnumerator;
NSString *key, *uid, *line;
NGVCard *vCard;
id value;

NSRange r;
int i, j, count, linesCount;
int rc;

Expand All @@ -172,9 +175,6 @@ - (int) importLdifData: (NSString *) ldifData

for (i = 0; i < count; i++)
{
SOGoContactLDIFEntry *ldifEntry;
NSEnumerator *keyEnumerator;
NSMutableDictionary *encodedEntry;
encodedEntry = [NSMutableDictionary dictionary];
lines = [[ldifContacts objectAtIndex: i]
componentsSeparatedByString: @"\n"];
Expand All @@ -183,7 +183,6 @@ - (int) importLdifData: (NSString *) ldifData
linesCount = [lines count];
for (j = 0; j < linesCount; j++)
{
NSString *line;
line = [lines objectAtIndex: j];

/* skip embedded comment lines */
Expand All @@ -199,17 +198,17 @@ - (int) importLdifData: (NSString *) ldifData
if (key != NULL)
{
value = [[encodedEntry valueForKey: key]
stringByAppendingString: [line substringFromIndex: 1]];
stringByAppendingString: [line substringFromIndex: 1]];
[encodedEntry setValue: value forKey: key];
}
continue;
}

components = [line componentsSeparatedByString: @": "];
if ([components count] == 2)
r = [line rangeOfString: @": "];
if (r.location != NSNotFound)
{
key = [[components objectAtIndex: 0] lowercaseString];
value = [components objectAtIndex: 1];
key = [[line substringToIndex: r.location] lowercaseString];
value = [line substringFromIndex: NSMaxRange(r)];

if ([key length] == 0)
key = @"dn";
Expand Down

0 comments on commit e46c51e

Please sign in to comment.