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

List:       kde-commits
Subject:    branches/KDE/3.5/kdepim
From:       Allen Winter <winter () kde ! org>
Date:       2008-04-23 17:09:33
Message-ID: 1208970573.378559.17840.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 800206 by winterz:

port SVN commit r800168 by ervin:

Apply the RFC2047 decoding inside of normalizeAddressesAndDecodeIdn() as
advised by Ingo. Use the RFC2047 implementation of kmime for that matter
(yes, we have at least three implementations of this rfc in kdepim).

Since the RFC2047 decoding is now done in normalizeAddressesAndDecodeIdn(),
use the raw headers for the relevant addresses related fields in KMMessage.




 M  +16 -6     kmail/kmmessage.cpp
 M  +1 -1      libemailfunctions/Makefile.am
 M  +5 -1      libemailfunctions/email.cpp
 M  +1 -1      libemailfunctions/tests/Makefile.am
 M  +11 -0     libemailfunctions/tests/testemail.cpp
 M  +5 -0      libkmime/kmime_util.cpp
 M  +7 -0      libkmime/kmime_util.h


--- branches/KDE/3.5/kdepim/kmail/kmmessage.cpp #800205:800206
@@ -1875,7 +1875,12 @@
 QString KMMessage::to() const
 {
   // handle To same as Cc below, bug 80747
-  return KPIM::normalizeAddressesAndDecodeIDNs( headerFields( "To" ).join( ", " ) );
+  QValueList<QCString> rawHeaders = rawHeaderFields( "To" );
+  QStringList headers;
+  for ( QValueList<QCString>::Iterator it = rawHeaders.begin(); it != \
rawHeaders.end(); ++it ) { +    headers << *it;
+  }
+  return KPIM::normalizeAddressesAndDecodeIDNs( headers.join( ", " ) );
 }


@@ -1894,7 +1899,7 @@
 //-----------------------------------------------------------------------------
 QString KMMessage::replyTo() const
 {
-  return KPIM::normalizeAddressesAndDecodeIDNs( headerField("Reply-To") );
+  return KPIM::normalizeAddressesAndDecodeIDNs( rawHeaderField("Reply-To") );
 }


@@ -1917,7 +1922,12 @@
 {
   // get the combined contents of all Cc headers (as workaround for invalid
   // messages with multiple Cc headers)
-  return KPIM::normalizeAddressesAndDecodeIDNs( headerFields( "Cc" ).join( ", " ) );
+  QValueList<QCString> rawHeaders = rawHeaderFields( "Cc" );
+  QStringList headers;
+  for ( QValueList<QCString>::Iterator it = rawHeaders.begin(); it != \
rawHeaders.end(); ++it ) { +    headers << *it;
+  }
+  return KPIM::normalizeAddressesAndDecodeIDNs( headers.join( ", " ) );
 }


@@ -1938,7 +1948,7 @@
 //-----------------------------------------------------------------------------
 QString KMMessage::bcc() const
 {
-  return KPIM::normalizeAddressesAndDecodeIDNs( headerField("Bcc") );
+  return KPIM::normalizeAddressesAndDecodeIDNs( rawHeaderField("Bcc") );
 }


@@ -1977,7 +1987,7 @@
 QString KMMessage::who() const
 {
   if (mParent)
-    return KPIM::normalizeAddressesAndDecodeIDNs( \
headerField(mParent->whoField().utf8()) ); +    return \
KPIM::normalizeAddressesAndDecodeIDNs( rawHeaderField(mParent->whoField().utf8()) );  \
return from();  }

@@ -1985,7 +1995,7 @@
 //-----------------------------------------------------------------------------
 QString KMMessage::from() const
 {
-  return KPIM::normalizeAddressesAndDecodeIDNs( headerField("From") );
+  return KPIM::normalizeAddressesAndDecodeIDNs( rawHeaderField("From") );
 }


--- branches/KDE/3.5/kdepim/libemailfunctions/Makefile.am #800205:800206
@@ -1,4 +1,4 @@
-INCLUDES = $(all_includes)
+INCLUDES = $(all_includes) -I../libkmime/

 noinst_LTLIBRARIES = libemailfunctions.la
 libemailfunctions_la_SOURCES = email.cpp idmapper.cpp kasciistricmp.cpp \
--- branches/KDE/3.5/kdepim/libemailfunctions/email.cpp #800205:800206
@@ -23,6 +23,7 @@
 #include <kdebug.h>
 #include <klocale.h>
 #include <kidna.h>
+#include <kmime_util.h>

 #include <qregexp.h>

@@ -803,7 +804,7 @@
   if ( displayName.isEmpty() && comment.isEmpty() )
     return addrSpec;
   else if ( comment.isEmpty() )
-    return displayName + " <" + addrSpec + ">";
+    return quoteNameIfNecessary( displayName ) + " <" + addrSpec + ">";
   else if ( displayName.isEmpty() ) {
     QString commentStr = comment;
     return quoteNameIfNecessary( commentStr ) + " <" + addrSpec + ">";
@@ -863,6 +864,9 @@
       if ( KPIM::splitAddress( (*it).utf8(), displayName, addrSpec, comment )
            == AddressOk ) {

+        displayName = KMime::decodeRFC2047String(displayName).utf8();
+        comment = KMime::decodeRFC2047String(comment).utf8();
+
         normalizedAddressList <<
           normalizedAddress( QString::fromUtf8( displayName ),
                              decodeIDN( QString::fromUtf8( addrSpec ) ),
--- branches/KDE/3.5/kdepim/libemailfunctions/tests/Makefile.am #800205:800206
@@ -1,5 +1,5 @@
 AM_CPPFLAGS = -I$(top_srcdir)/libemailfunctions $(all_includes)
-LDADD = ../libemailfunctions.la $(LIB_KDECORE)
+LDADD = ../libemailfunctions.la ../../libkmime/libkmime.la $(LIB_KDECORE)

 check_PROGRAMS = testidmapper testemail
 TESTS = testemail
--- branches/KDE/3.5/kdepim/libemailfunctions/tests/testemail.cpp #800205:800206
@@ -144,6 +144,13 @@
   return true;
 }

+static bool checkNormalizeAddressesAndDecodeIDNs( const QString& input, const \
QString& expResult ) +{
+  QString result = KPIM::normalizeAddressesAndDecodeIDNs( input );
+  check( "normalizeAddressesAndDecodeIDNs( \"" + input + "\" ) result ", result, \
expResult ); +  return true;
+}
+
 static bool checkQuoteIfNecessary( const QString& input, const QString& expResult )
 {
   QString result = quoteNameIfNecessary( input );
@@ -458,6 +465,10 @@
   checkNormalizeAddressesAndEncodeIDNs( "matt@fruitsalad.org (jongel,fibbel)", \
"\"jongel,fibbel\" <matt@fruitsalad.org>" );  checkNormalizeAddressesAndEncodeIDNs( \
"matt@fruitsalad.org (\"jongel,fibbel\")", "\"jongel,fibbel\" <matt@fruitsalad.org>" \
);

+  // check checkNormalizeAddressesAndDecodeIDNs
+  checkNormalizeAddressesAndDecodeIDNs( "=?us-ascii?Q?Surname, Name?= \
<nobody@example.org>", "\"Surname, Name\" <nobody@example.org>" ); +  \
checkNormalizeAddressesAndDecodeIDNs( "=?iso-8859-1?B?5Hf8b2xmLPZBbmRyZWFz?= \
<nobody@example.org>", QString::fromUtf8("\"äwüolf,öAndreas\" \
<nobody@example.org>") ); +
   // check the "quote if necessary" method
   checkQuoteIfNecessary( "Matt Douhan", "Matt Douhan");
   checkQuoteIfNecessary( "Douhan, Matt", "\"Douhan, Matt\"");
--- branches/KDE/3.5/kdepim/libkmime/kmime_util.cpp #800205:800206
@@ -235,6 +235,11 @@
   return codec->toUnicode(result.data(), result.length());
 }

+QString decodeRFC2047String(const QCString &src)
+{
+  const char *usedCS;
+  return decodeRFC2047String(src, &usedCS, "utf-8", false);
+}

 QCString encodeRFC2047String(const QString &src, const char *charset,
 			     bool addressHeader, bool allow8BitHeaders)
--- branches/KDE/3.5/kdepim/libkmime/kmime_util.h #800205:800206
@@ -77,6 +77,13 @@
   extern QString decodeRFC2047String(const QCString &src, const char **usedCS,
 				     const QCString &defaultCS, bool forceCS) KDE_EXPORT;

+  /** Decode string @p src according to RFC2047 (ie. the
+      =?charset?[qb]?encoded?= construct).
+      @param src       source string.
+      @return the decoded string.
+  */
+  extern QString decodeRFC2047String(const QCString &src) KDE_EXPORT;
+
   /** Encode string @p src according to RFC2047 using charset
       @p charset.
       @param src           source string.


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

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