From 7a9db510f5c126d915cab841ab4e00afbd9895a4 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Wed, 12 Dec 2012 14:56:07 +0100 Subject: [PATCH] Do not re-encode data if it is already encoded (thanks to Mehmet Bozkurt). --- src/encoding.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/encoding.cpp b/src/encoding.cpp index 343a8223..4570237d 100644 --- a/src/encoding.cpp +++ b/src/encoding.cpp @@ -187,6 +187,10 @@ const encoding encoding::decideImpl const encoding encoding::decide (ref data, const EncodingUsage usage) { + // Do not re-encode data if it is already encoded + if (data->isEncoded() && data->getEncoding() == encoding(encodingTypes::BASE64)) + return data->getEncoding(); + encoding enc; if (usage == USAGE_TEXT && data->isBuffered() && @@ -215,6 +219,10 @@ const encoding encoding::decide const encoding encoding::decide(ref 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)) + return data->getEncoding(); + if (usage == USAGE_TEXT) { encoding recEncoding;