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

List:       kde-pim
Subject:    [Kde-pim] 3.3 Patch: Bugfixing libkdepim/email.cpp
From:       Karl-Heinz Zimmer <khz () kde ! org>
Date:       2004-08-19 10:36:43
Message-ID: 200408191236.48285 () postmaster ! bugcops ! org
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

please review the attached patch and tell me if I may commit it to
KDE_3_3_BRANCH and to the HEAD branch.

Problem was: KPIM::getNameAndMail(...) cut the name when finding a ','
             even if that ',' was inside a "..." quoted text part.

So "\"Doe, Joe\" <jd@kde.org>" did result in this name:  Joe"

Thank you

Karl-Heinz
- -- 
Karl-Heinz         <mailto:khz@indeview.org>        <mailto:khz@kde.org>
  Zimmer                I n d e V i e w                    K D E
  Föhren       Presentations Beyond Limitations     Conquer your Desktop
www.fiehr.de            www.indeview.org                www.kde.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQFBJIK/CcaVnbvggDcRAukJAKCZ98UDgNQQXL5o1Ht0eLSbHki32wCgrPAw
JgT9Sp17e3vP4RiLM6LOWwg=
=cJai
-----END PGP SIGNATURE-----

["kdepim_libkdepim_email.cpp.PATCH" (text/x-diff)]

Index: email.cpp
===================================================================
RCS file: /home/kde/kdepim/libkdepim/email.cpp,v
retrieving revision 1.3
diff -u -p -r1.3 email.cpp
--- email.cpp	16 Jul 2004 11:59:52 -0000	1.3
+++ email.cpp	19 Aug 2004 10:24:43 -0000
@@ -136,8 +136,9 @@ bool KPIM::getNameAndMail(const QString&
   mail = QString::null;
 
   const int len=aStr.length();
-
-  bool bInComment;
+  const char cQuotes = '"';
+  
+  bool bInComment, bInQuotesOutsideOfEmail;
   int i=0, iAd=0, iMailStart=0, iMailEnd=0;
   QChar c;
 
@@ -179,8 +180,10 @@ bool KPIM::getNameAndMail(const QString&
   }else{
 
     // Loop backwards until we find the start of the string
-    // or a ',' outside of a comment.
+    // or a ',' that is outside of a comment
+    //          and outside of quoted text before the leading '<'.
     bInComment = false;
+    bInQuotesOutsideOfEmail = false;
     for( i = iAd-1; 0 <= i; --i ) {
       c = aStr[i];
       if( bInComment ){
@@ -191,12 +194,18 @@ bool KPIM::getNameAndMail(const QString&
         }else{
           name.prepend( c ); // all comment stuff is part of the name
         }
+      }else if( bInQuotesOutsideOfEmail ){
+        if( cQuotes == c )
+          bInQuotesOutsideOfEmail = false;
+        name.prepend( c );
       }else{
         // found the start of this addressee ?
         if( ',' == c )
           break;
         // stuff is before the leading '<' ?
         if( iMailStart ){
+          if( cQuotes == c )
+            bInQuotesOutsideOfEmail = true; // end of quoted text found
           name.prepend( c );
         }else{
           switch( c ){
@@ -225,8 +234,10 @@ bool KPIM::getNameAndMail(const QString&
     mail.append('@');
 
     // Loop forward until we find the end of the string
-    // or a ',' outside of a comment.
+    // or a ',' that is outside of a comment 
+    //          and outside of quoted text behind the trailing '>'.
     bInComment = false;
+    bInQuotesOutsideOfEmail = false;
     for( i = iAd+1; len > i; ++i ) {
       c = aStr[i];
       if( bInComment ){
@@ -237,12 +248,18 @@ bool KPIM::getNameAndMail(const QString&
         }else{
           name.append( c ); // all comment stuff is part of the name
         }
+      }else if( bInQuotesOutsideOfEmail ){
+        if( cQuotes == c )
+          bInQuotesOutsideOfEmail = false;
+        name.append( c );
       }else{
         // found the end of this addressee ?
         if( ',' == c )
           break;
-        // stuff is behind the trailing '<' ?
+        // stuff is behind the trailing '>' ?
         if( iMailEnd ){
+          if( cQuotes == c )
+            bInQuotesOutsideOfEmail = true; // start of quoted text found
           name.append( c );
         }else{
           switch( c ){
@@ -265,6 +282,6 @@ bool KPIM::getNameAndMail(const QString&
 
   name = name.simplifyWhiteSpace();
   mail = mail.simplifyWhiteSpace();
-
+  
   return ! (name.isEmpty() || mail.isEmpty());
 }


_______________________________________________
kde-pim mailing list
kde-pim@mail.kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/

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

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