Checks for a charset in all words of a parameter in a parameterizedHeader.

Fixes filename encoding when the quoted-printable starts halfway, but
if multiple charsets are used (unlikely) it may still fail (thanks to
Zarafa).
This commit is contained in:
Vincent Richard 2013-03-24 11:29:03 +01:00
parent 555dcca979
commit 1d04b0a579

View File

@ -234,7 +234,7 @@ void parameter::parse(const parsingContext& ctx, const std::vector <valueChunk>&
// This syntax is non-standard (expressly prohibited
// by RFC-2047), but is used by Mozilla:
//
// Content-Type: image/png;
// Content-Type: image/png;
// name="=?us-ascii?Q?Logo_VMime=2Epng?="
// Using 'vmime::text' to parse the data is safe even
@ -248,7 +248,20 @@ void parameter::parse(const parsingContext& ctx, const std::vector <valueChunk>&
value << t.getWholeBuffer();
if (!foundCharsetChunk)
ch = t.getWordAt(0)->getCharset();
{
// This is still wrong. Each word can have it's own charset, and can
// be mixed (eg. iso-8859-1 and iso-2022-jp), but very unlikely. Real
// fix is to have parameters store a vmime::text instead of a
// vmime::word in m_value. But that changes the interface.
for (size_t i = 0 ; i < t.getWordCount() ; ++i)
{
if (t.getWordAt(i)->getCharset() != ch && ch == charsets::US_ASCII)
{
ch = t.getWordAt(i)->getCharset();
break;
}
}
}
}
}
}