[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdelibs/kabc/scripts
From:       Daniel Molkentin <molkentin () kde ! org>
Date:       2003-06-30 21:39:03
[Download RAW message or body]

CVS commit by danimo: 

Fix for "email addresses of type "email@foo.bar (Name)" do not get parsed correctly"

CCMAIL: 54853-done@kde.org


  M +18 -5     addressee.src.cpp   1.45


--- kdelibs/kabc/scripts/addressee.src.cpp  #1.44:1.45
@@ -793,8 +793,19 @@ void Addressee::parseEmailAddress( const
 
       // Grab the name part
-      fullName = rawEmail.left(startPos).stripWhiteSpace();
-
+      QString left = rawEmail.left(startPos).stripWhiteSpace();
       // grab the email part
-      email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace();
+      QString right = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace();
+
+      // Either "Name <email>" or "email (Name)"
+      if (endCh == '>')
+      {
+        fullName = left;
+        email = right;
+      }
+      else // endCh == ')'
+      {
+        fullName = right;
+        email = left;
+      }
 
       // Check that we do not have any extra characters on the end of the
@@ -803,8 +814,10 @@ void Addressee::parseEmailAddress( const
       if (fullName[0]=='"' && fullName[len-1]=='"')
         fullName = fullName.mid(1, len-2);
-      else if (fullName[0]=='<' && fullName[len-1]=='>')
-        fullName = fullName.mid(1, len-2);
       else if (fullName[0]=='(' && fullName[len-1]==')')
         fullName = fullName.mid(1, len-2);
+
+          len = email.length();
+      if (email[0]=='<' && email[len-1]=='>')
+        email = email.mid(1, len-2);
     }
   }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic