Also do not re-encode Quoted-Printable and UUEncode.
This commit is contained in:
parent
3a5621c2aa
commit
e91495e3c3
@ -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
|
const encoding encoding::decide
|
||||||
(ref <const contentHandler> data, const EncodingUsage usage)
|
(ref <const contentHandler> data, const EncodingUsage usage)
|
||||||
{
|
{
|
||||||
// Do not re-encode data if it is already encoded
|
// 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();
|
return data->getEncoding();
|
||||||
|
|
||||||
encoding enc;
|
encoding enc;
|
||||||
@ -220,7 +233,7 @@ const encoding encoding::decide(ref <const contentHandler> data,
|
|||||||
const charset& chset, const EncodingUsage usage)
|
const charset& chset, const EncodingUsage usage)
|
||||||
{
|
{
|
||||||
// Do not re-encode data if it is already encoded
|
// 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();
|
return data->getEncoding();
|
||||||
|
|
||||||
if (usage == USAGE_TEXT)
|
if (usage == USAGE_TEXT)
|
||||||
|
@ -130,6 +130,13 @@ private:
|
|||||||
string m_name;
|
string m_name;
|
||||||
EncodingUsage m_usage;
|
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.
|
/** Decide which encoding to use based on the specified data.
|
||||||
*
|
*
|
||||||
* Please note: this will read the whole buffer, so it should be used only
|
* Please note: this will read the whole buffer, so it should be used only
|
||||||
|
Loading…
Reference in New Issue
Block a user