From 1d04b0a57901d85e802c0cca601d15f7dd751a44 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Sun, 24 Mar 2013 11:29:03 +0100 Subject: [PATCH] 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). --- src/parameter.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/parameter.cpp b/src/parameter.cpp index 37a59890..b86d4815 100644 --- a/src/parameter.cpp +++ b/src/parameter.cpp @@ -234,7 +234,7 @@ void parameter::parse(const parsingContext& ctx, const std::vector & // 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 & 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; + } + } + } } } }