aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/encoding.cpp17
-rw-r--r--vmime/encoding.hpp7
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