diff options
author | Vincent Richard <[email protected]> | 2012-12-13 12:16:52 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2012-12-13 12:16:52 +0000 |
commit | e91495e3c3b219fd890d877f96f48a00255c196c (patch) | |
tree | 6a3304f12e85a9d66235c595c78263b1fa218a57 | |
parent | Trivial 64-bit warning fixes. (diff) | |
download | vmime-e91495e3c3b219fd890d877f96f48a00255c196c.tar.gz vmime-e91495e3c3b219fd890d877f96f48a00255c196c.zip |
Also do not re-encode Quoted-Printable and UUEncode.
-rw-r--r-- | src/encoding.cpp | 17 | ||||
-rw-r--r-- | vmime/encoding.hpp | 7 |
2 files changed, 22 insertions, 2 deletions
diff --git a/src/encoding.cpp b/src/encoding.cpp index 4570237d..d2f1f23f 100644 --- a/src/encoding.cpp +++ b/src/encoding.cpp @@ -184,11 +184,24 @@ const encoding encoding::decideImpl } +bool encoding::shouldReencode() const +{ + if (m_name == encodingTypes::BASE64 || + m_name == encodingTypes::QUOTED_PRINTABLE || + m_name == encodingTypes::UUENCODE) + { + return false; + } + + return true; +} + + const encoding encoding::decide (ref <const contentHandler> data, const EncodingUsage usage) { // Do not re-encode data if it is already encoded - if (data->isEncoded() && data->getEncoding() == encoding(encodingTypes::BASE64)) + if (data->isEncoded() && !data->getEncoding().shouldReencode()) return data->getEncoding(); encoding enc; @@ -220,7 +233,7 @@ const encoding encoding::decide(ref <const contentHandler> data, const charset& chset, const EncodingUsage usage) { // Do not re-encode data if it is already encoded - if (data->isEncoded() && data->getEncoding() == encoding(encodingTypes::BASE64)) + if (data->isEncoded() && !data->getEncoding().shouldReencode()) return data->getEncoding(); if (usage == USAGE_TEXT) diff --git a/vmime/encoding.hpp b/vmime/encoding.hpp index 4322b298..1cd98121 100644 --- a/vmime/encoding.hpp +++ b/vmime/encoding.hpp @@ -130,6 +130,13 @@ private: string m_name; EncodingUsage m_usage; + /** Determine whether data encoded using this encoding should + * be re-encoded if needed. + * + * @return true if data should be re-encoded, false otherwise + */ + bool shouldReencode() const; + /** Decide which encoding to use based on the specified data. * * Please note: this will read the whole buffer, so it should be used only |