View Issue Details

IDProjectCategoryView StatusLast Update
0001340SOGoWeb Calendarpublic2012-08-27 15:51
Reportermra Assigned Tofrancis  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version1.3.7a 
Target Version1.3.18 
Summary0001340: Calendar Invitiation with strange splitted Email-Sender
Description
  • The convention for all usernames (not the ID!) in database and/or LDAP are
    "surname, christian-name"

Now:

  • Create a new event
  • Invite someone
  • Look at your own name (see Screenshot 1) - it is written correct
  • No save the event
  • Mail comes and the sender name (your own name) is splitted in two (unknown)
    (Screenshot 2)

I. E.:
The Sender Martin Rabl <martin@rablnet.de> becomes to
Martin@sending.mailserver.de and Rabl@sending.mailserver.de

This behaviour can be seen in LDAP and Database-driven SOGos.

Tagsinvite

Activities

2011-06-21 13:37

 

2011-06-21 13:39

 

2011-06-21 13:43

 

mra

mra

2011-06-21 13:43

reporter   ~0002614

Last edited: 2011-06-21 13:46

Please consider the order of the screenshots which illustrate the issue.

  1. name-splitting-in-email-addresses03.png (Invitation)
  2. name-splitting-in-email-addresses01.png (received Mail with false addresses)
  3. name-splitting-in-email-addresses02.png (That the source of the email)
mra

mra

2011-07-28 20:43

reporter   ~0002754

The file 'NGMailAddressParser.m' in SOPE seems to be a little buggy and splits not correct. Will search a solution.

mra

mra

2011-08-18 05:39

reporter   ~0002808

I'm working on a patch.

ludovic

ludovic

2011-11-24 20:39

administrator   ~0003070

Any update on the patch?

mra

mra

2011-11-24 22:47

reporter   ~0003078

Sorry, had to make a break (private issue, newborn in house ;-) ), but is on my list.

ludovic

ludovic

2011-12-30 16:55

administrator   ~0003229

Any update?

mra

mra

2011-12-30 21:06

reporter   ~0003244

Want to make a solution on january, had found the error, but a possible solution could be a rewrite of the class (worst case) where the error is.
Maybe there is another way, I try it next week.

mra

mra

2012-01-20 13:56

reporter   ~0003299

Ok, studied the code, tried some hacks and did come to the opinion, its better to reimplement that class - too much old code in C what IMHO could be made nicer in OOP with objc.

Some greps over SOPE/SOGo-src-tree showed me, there are relativly little dependencies on some methods (better: method calls) so the idea is to replace the old class with the new which only implements the called methods (public scope, I think).
But I'm not sure, if this does "polute" the SOPE-code in an improper way.
Or is it in a fixed state for SOGo?

esco

esco

2012-04-13 13:34

reporter   ~0003731

Hello,

we have the same problem when the name contains brackets.

esco

mra

mra

2012-04-19 13:08

reporter   ~0003775

New note: same problem in the list of mails (Inbox etc.).

Sorry, so far I hadn't time to write the suggested code ... :-/

Still the best solution is IMHO a rewrite.

mra

mra

2012-07-10 17:15

reporter   ~0004119

Still in heavy work ... but thinking on the problem.

mra

mra

2012-08-02 10:04

reporter   ~0004244

Attached my patch for this issue, which works pretty well (created against SOGo-2.0-Code, but runs IMHO in 1.3.17|.18 ..., too)

2012-08-02 10:05

 

patch_for_NGMailAddressParser.diff (4,863 bytes)   
#
# old_revision [9fcf97eb10d5be9ee65cc8ce8bf5651e02b25534]
#
# patch "sope-mime/NGMail/NGMailAddressParser.h"
#  from [24b3288dfb1dd3b55db39562b58c17f89760960c]
#    to [7594a40e7152dc0dfe5f6e8fecb20fdce0895b4b]
# 
# patch "sope-mime/NGMail/NGMailAddressParser.m"
#  from [79eb483d27176206aaa9ec109fab7b99957ee30f]
#    to [a9d54e0521c106939819dc163c2a08657ae22ad2]
#
============================================================
--- sope-mime/NGMail/NGMailAddressParser.h	24b3288dfb1dd3b55db39562b58c17f89760960c
+++ sope-mime/NGMail/NGMailAddressParser.h	7594a40e7152dc0dfe5f6e8fecb20fdce0895b4b
@@ -46,6 +46,7 @@
 + (id)mailAddressParserWithData:(NSData *)_data;
 + (id)mailAddressParserWithCString:(const char *)_cString;
 - (id)initWithString:(NSString *)_str;
++ (id)sanitizeMailAddresses:(NSString *)_string;
 
 /* parsing */
 
============================================================
--- sope-mime/NGMail/NGMailAddressParser.m	79eb483d27176206aaa9ec109fab7b99957ee30f
+++ sope-mime/NGMail/NGMailAddressParser.m	a9d54e0521c106939819dc163c2a08657ae22ad2
@@ -362,12 +362,110 @@ static inline id parseDomainLiteral(NGMa
 }
 
 + (id)mailAddressParserWithString:(NSString *)_string {
-  return [[(NGMailAddressParser *)[self alloc] initWithString:_string] 
+
+  return [[(NGMailAddressParser *)[self alloc] initWithString: [NGMailAddressParser sanitizeMailAddresses:_string]] 
 	   autorelease];
 }
 
++ (id) sanitizeMailAddresses:(NSString *)_string {
+
+    // Before init ... full replacement of quotes and double quotes - we don't need them anymore ;-)
+    NSMutableString* _addr = [NSMutableString stringWithString:_string];
+    [_addr replaceString:@"'" withString:@""];
+    [_addr replaceString:@"\"" withString:@""];
+    NSString* addresses = (NSString *)_addr;
+    
+    // Init
+    BOOL isDisplayNameEnd = NO;
+    BOOL hasAt = NO;
+    long lastPos = 0;
+    long displayNameEndPos = 0;
+    long mailEndPos = 0;
+    long len = [addresses length];
+    NSString* mailAdr= @"";
+    NSString* displayName = @"";
+    NSMutableArray* _addressList = [NSMutableArray arrayWithCapacity:1];
+    
+    
+    // step through the chars
+    long i;
+    for (i=0; i < len; i++) {
+        char cai = [addresses characterAtIndex:i]; // get every char
+      
+        if(cai == ' ') continue; // skip spaces
+
+        
+        if (cai == '@') {
+            hasAt = YES;
+            continue;
+        }
+        
+        if(cai == '<')
+        {
+            isDisplayNameEnd = YES;
+            displayNameEndPos = i;
+        }
+        
+        if(cai == '>')
+        {
+            mailEndPos = i;
+        }
+        
+        if ((cai == ',' && hasAt) || ((i + 1) == len)) {
+            
+            mailAdr = @"";
+            displayName = @"";
+            
+            if(isDisplayNameEnd)
+            {
+                displayName = [[addresses substringWithRange: NSMakeRange(lastPos, displayNameEndPos - lastPos)] stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
+            }
+            
+            // If there a displayname, get mailAdr on an other way
+            if([displayName length] > 0)
+            {
+                mailAdr = [[addresses stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]] substringWithRange: NSMakeRange(displayNameEndPos + 1, mailEndPos - displayNameEndPos - 1)];
+            }
+            else
+            {
+                mailAdr = [[addresses substringWithRange: NSMakeRange(lastPos, i-lastPos)] stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
+            }
+
+            // trim spaces of mailAdr
+            mailAdr = [mailAdr stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
+        
+
+            // Format new mail string into an array
+            if([displayName length] == 0)
+            {
+                [_addressList addObject: [NSString stringWithFormat:@"%@",mailAdr]];
+            }
+            else
+            {
+                [_addressList addObject: [NSString stringWithFormat:@"\"%@\" <%@>",displayName,mailAdr]];    
+            }
+            
+            
+            // Reset and set
+            lastPos = i+1;
+            hasAt = NO;
+            isDisplayNameEnd = NO;   
+            
+            // next step ;-)
+            continue;
+        }
+        
+    }
+    
+    // Concatenate the array items to a string by comma and returns it
+    return [_addressList componentsJoinedByString:@","];
+}
+
 - (id)initWithString:(NSString *)_str {
   if ((self = [super init])) {
+
+    _str = [NGMailAddressParser sanitizeMailAddresses:_str];
+
     // TODO: remember some string encoding?
     self->maxLength = [_str length];
     self->data      = malloc(self->maxLength*sizeof(unichar));
francis

francis

2012-08-27 15:51

administrator   ~0004381

Fixed in 511791fc5bfb5cf1f56266a5c55753aa26f958b8. Thanks for the patch!

Issue History

Date Modified Username Field Change
2011-06-21 13:37 mra New Issue
2011-06-21 13:37 mra File Added: name-splitting-in-email-addresses01.png
2011-06-21 13:39 mra File Added: name-splitting-in-email-addresses02.png
2011-06-21 13:43 mra File Added: name-splitting-in-email-addresses03.png
2011-06-21 13:43 mra Note Added: 0002614
2011-06-21 13:45 mra Note Edited: 0002614
2011-06-21 13:46 mra Note Edited: 0002614
2011-06-21 13:46 mra Tag Attached: invite
2011-07-28 20:43 mra Note Added: 0002754
2011-08-18 05:39 mra Note Added: 0002808
2011-11-24 20:39 ludovic Note Added: 0003070
2011-11-24 22:47 mra Note Added: 0003078
2011-12-30 16:55 ludovic Note Added: 0003229
2011-12-30 21:06 mra Note Added: 0003244
2012-01-20 13:56 mra Note Added: 0003299
2012-04-13 13:34 esco Note Added: 0003731
2012-04-19 13:08 mra Note Added: 0003775
2012-07-10 17:15 mra Note Added: 0004119
2012-08-02 10:04 mra Note Added: 0004244
2012-08-02 10:05 mra File Added: patch_for_NGMailAddressParser.diff
2012-08-03 19:21 francis Target Version => 1.3.18
2012-08-27 15:09 francis Status new => assigned
2012-08-27 15:09 francis Assigned To => francis
2012-08-27 15:51 francis Note Added: 0004381
2012-08-27 15:51 francis Status assigned => resolved
2012-08-27 15:51 francis Resolution open => fixed