Revision: 7352
          http://mahogany.svn.sourceforge.net/mahogany/?rev=7352&view=rev
Author:   vadz
Date:     2007-08-30 10:46:14 -0700 (Thu, 30 Aug 2007)

Log Message:
-----------
show badly formed UTF-8 text message parts as latin1 instead of not showing 
them at all

Modified Paths:
--------------
    trunk/M/src/mail/MimePartCCBase.cpp

Modified: trunk/M/src/mail/MimePartCCBase.cpp
===================================================================
--- trunk/M/src/mail/MimePartCCBase.cpp 2007-08-30 00:14:55 UTC (rev 7351)
+++ trunk/M/src/mail/MimePartCCBase.cpp 2007-08-30 17:46:14 UTC (rev 7352)
@@ -281,7 +281,31 @@
       // it's still the right choice
       if ( m_encoding == wxFONTENCODING_SYSTEM ||
             m_encoding == wxFONTENCODING_DEFAULT )
+      {
          m_encoding = wxFONTENCODING_ISO8859_1;
+      }
+
+      // special case: many broken programs generate messages with UTF-8
+      // charset but without properly encoding the contents in UTF-8 which
+      // results in "s" being empty and not showing the text parts at all
+      //
+      // so if the conversion failed, try to show the text at least somehow
+      // using latin1 (and the user will be able to change the encoding
+      // manually from the menu later which would be impossible if we returned
+      // an empty string from GetTextContent())
+      if ( m_encoding == wxFONTENCODING_UTF8 ||
+            m_encoding == wxFONTENCODING_UTF7 )
+      {
+         // check if we really have valid UTF-x
+         unsigned long len;
+         const char *p = reinterpret_cast<const char *>(GetContent(&len));
+
+         if ( p &&
+               wxCSConv(m_encoding).ToWChar(NULL, 0, p, len) == wxCONV_FAILED )
+         {
+            m_encoding = wxFONTENCODING_ISO8859_1;
+         }
+      }
    }
 
    return m_encoding;


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to