Hi Jeff,
thanks a lot for your fast
reply and bugfix.
I have applied your patch
and it seems to be correct now.
And your changes are better
than mine, because you use the native Windows function GetACP() instead of
g_get_charset() which doesn't seem to work correct on Windows Server 2008. That
was one of the problems I'm fighting with on Friday.
On my developer maschine
with Windows XP my workaround works like expected but if I run it on a Windows
Server 2008 maschine the g_get_charset() function does not return the correct
charset I think - I could not verify this in deep, but after using GetACP() it
works.
Another weird thing is that
if I call g_mime_parser_construct_message() twice for the same eml file (in
different functions and everytime surrounded with g_mime_init() and
g_mime_shutdown()) the second time the library hangs at the same iconv
call.
But now the errno
is E2BIG which is incorrect because all the buffers seem to be ok.
This happen only if the
gmime tries to convert from UTF-8 to UTF-8 - so I decided to change the order of
the calls in g_mime_utils_decode_8bit() function - by adding the locale charset
to the charsets array first.
if (!(included &
USER_CHARSETS_INCLUDE_LOCALE))
charsets[i++] = locale; if (!(included &
USER_CHARSETS_INCLUDE_LATIN1))
charsets[i++] = "iso-8859-1"; if (!(included &
USER_CHARSETS_INCLUDE_UTF8))
charsets[i++] = "UTF-8"; The strange thing is, that
this is not reproducable with any eml file - I've found only one which results
in the hang. I have attached the file - so maybe you are able to find a better
workaround for that.
Maybe this is a problem with
my code - it not clear to me which memory I have to free or not.
Here is what I'm
calling:
//
ParseEML
// //------------------------------------------------------------------------------ void CEMLExporter::ParseEML(boost::filesystem::path& inEMLFile, std::map<std::wstring, std::wstring>& inoutHeaderFieldValues) { FILE *fp = NULL; GMimeParser *parser = NULL; GMimeStream *gfs = NULL; GMimeMessage *message = NULL; GMimeObject *part = NULL; fopen_s(&fp,
inEMLFile.string().c_str(), "r");
g_mime_init(0);
gfs = g_mime_stream_file_new(fp); if(gfs) { parser = g_mime_parser_new_with_stream(gfs); if(parser) { message = g_mime_parser_construct_message(parser); std::map<std::wstring,
std::wstring>::const_iterator fieldIter;
for(fieldIter = mConfig->mEMLHeaderFields.begin(); fieldIter != mConfig->mEMLHeaderFields.end(); ++fieldIter) { if(fieldIter->first == L"Subject") { inoutHeaderFieldValues[fieldIter->second] = str_to_wstr(g_mime_message_get_subject(message), CP_UTF8); } else if(fieldIter->first == L"Date") { std::string rfc822DateString = g_mime_message_get_date_as_string(message); inoutHeaderFieldValues[fieldIter->second]
=
GetDateTimeStringFromRFC822(rfc822DateString);
//inoutHeaderFieldValues[fieldIter->second] = GetDataTime(message); } else if(fieldIter->first == L"From") { inoutHeaderFieldValues[fieldIter->second] = str_to_wstr(g_mime_message_get_sender(message), CP_UTF8); } else if(fieldIter->first == L"To") { std::vector<std::string> recipients; GetRecipients(message, GMIME_RECIPIENT_TYPE_TO, recipients); GetRecipients(message, GMIME_RECIPIENT_TYPE_CC, recipients); GetRecipients(message, GMIME_RECIPIENT_TYPE_BCC, recipients); inoutHeaderFieldValues[fieldIter->second]
= str_to_wstr(boost::algorithm::join(recipients, ","),
CP_UTF8);
} } } } g_mime_shutdown(); fclose(fp); }
Best regards
Bastian
To: fejj gnome org Cc: gmime-devel-list gnome org |
--- Begin Message ---
- From: "Dirk Olschewski" <dolschew codesco com>
- To: "Klaus Behnke" <kbehnke codesco com>, "Sönke Brohman" <SBrohmann codesco com>
- Subject: ex ProdTrack 6_3.0.1b1 für Windows auf ex Testex Test
- Date: Sat, 2 Jul 2005 12:19:15 +0000
--- End Message ---