mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-27 03:43:25 +01:00
only convert encoded-word if explicitly requested
This commit is contained in:
parent
0dfc1bdbf9
commit
64becc6266
@ -824,7 +824,7 @@ std::string MailMessage::decodeWord(const std::string& charset,
|
|||||||
TextEncoding* fromEnc = registry.find(charset);
|
TextEncoding* fromEnc = registry.find(charset);
|
||||||
TextEncoding* toEnc = registry.find(toCharset);
|
TextEncoding* toEnc = registry.find(toCharset);
|
||||||
|
|
||||||
std::string tmpStr, decoded;
|
std::string decoded;
|
||||||
switch (encoding)
|
switch (encoding)
|
||||||
{
|
{
|
||||||
case 'B': case 'b':
|
case 'B': case 'b':
|
||||||
@ -836,13 +836,7 @@ std::string MailMessage::decodeWord(const std::string& charset,
|
|||||||
std::vector<unsigned char> wideCharSeq;
|
std::vector<unsigned char> wideCharSeq;
|
||||||
for (const auto& c : text)
|
for (const auto& c : text)
|
||||||
{
|
{
|
||||||
/*if (!Ascii::isPrintable(c) || Ascii::isSpace(c) || c == '?')
|
if (c == '_') decoded.append(1, ' ');
|
||||||
{
|
|
||||||
throw InvalidArgumentException(Poco::format("MailMessage::decodeWord: "
|
|
||||||
"invalid character found in encoded-word: %X", (unsigned)c));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if (c == '_') tmpStr.append(1, ' ');
|
|
||||||
else if (c == '=') isWide = true;
|
else if (c == '=') isWide = true;
|
||||||
else if (isWide)
|
else if (isWide)
|
||||||
{
|
{
|
||||||
@ -858,7 +852,7 @@ std::string MailMessage::decodeWord(const std::string& charset,
|
|||||||
auto end = wideCharSeq.end();
|
auto end = wideCharSeq.end();
|
||||||
for (; it != end; ++it)
|
for (; it != end; ++it)
|
||||||
{
|
{
|
||||||
tmpStr.append(1, static_cast<char>(*it));
|
decoded.append(1, static_cast<char>(*it));
|
||||||
}
|
}
|
||||||
wideChar.clear();
|
wideChar.clear();
|
||||||
wideCharSeq.clear();
|
wideCharSeq.clear();
|
||||||
@ -866,16 +860,21 @@ std::string MailMessage::decodeWord(const std::string& charset,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else tmpStr.append(1, c);
|
else decoded.append(1, c);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
throw InvalidArgumentException(Poco::format("MailMessage::decodeWord: Unknown encoding: %c", encoding));
|
throw InvalidArgumentException(Poco::format("MailMessage::decodeWord: Unknown encoding: %c", encoding));
|
||||||
}
|
}
|
||||||
TextConverter converter(*fromEnc, *toEnc);
|
if (charset != toCharset)
|
||||||
converter.convert(tmpStr, decoded);
|
{
|
||||||
return decoded;
|
TextConverter converter(*fromEnc, *toEnc);
|
||||||
|
std::string converted;
|
||||||
|
converter.convert(decoded, converted);
|
||||||
|
return std::move(converted);
|
||||||
|
}
|
||||||
|
return std::move(decoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user