diff options
author | Don Sanders <don.sanders@nokia.com> | 2012-01-02 13:36:36 +0200 |
---|---|---|
committer | Don Sanders <don.sanders@nokia.com> | 2012-01-02 13:36:36 +0200 |
commit | 1be06140d7c0f4e976a934f79609d24d5535a04b (patch) | |
tree | 15a164ad78704d0f26bccafbf53e26123645c5b2 /src/libraries/qmfclient/qmailmessage.cpp | |
parent | 199908c8a14e78e98e65f229e6f4b48446bf41b2 (diff) |
In ensureCharsetExists don't set empty charset
Follow up fix for NB#294947.
Required to make unit tests pass, otherwise Content-Type header
field output by QMailMessage::toRfc2822 has a spurious empty
charset parameter e.g.
Content-Type: text/plain; charset=
Instead of
Content-Type: text/plain;
Diffstat (limited to 'src/libraries/qmfclient/qmailmessage.cpp')
-rw-r--r-- | src/libraries/qmfclient/qmailmessage.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/libraries/qmfclient/qmailmessage.cpp b/src/libraries/qmfclient/qmailmessage.cpp index e1de6dfd..73b40b38 100644 --- a/src/libraries/qmfclient/qmailmessage.cpp +++ b/src/libraries/qmfclient/qmailmessage.cpp @@ -3152,7 +3152,10 @@ void QMailMessageBodyPrivate::ensureCharsetExist() if (_type.type().toLower() != "text" || (_type.subType().toLower() != "plain" && _type.subType().toLower() != "html")) { - _type.setCharset(QMailCodec::bestCompatibleCharset(_type.charset(), true)); + QByteArray best(QMailCodec::bestCompatibleCharset(_type.charset(), true)); + if (!best.isEmpty()) { + _type.setCharset(best); + } return; } @@ -3178,10 +3181,16 @@ void QMailMessageBodyPrivate::ensureCharsetExist() autoCharset = QMailCodec::autoDetectEncoding(data).toLatin1(); } if (!autoCharset.isEmpty() && (insensitiveIndexOf("ISO-8859-", autoCharset) == -1)) { - _type.setCharset(QMailCodec::bestCompatibleCharset(autoCharset, true)); + QByteArray best(QMailCodec::bestCompatibleCharset(autoCharset, true)); + if (!best.isEmpty()) { + _type.setCharset(best); + } } } else { - _type.setCharset(QMailCodec::bestCompatibleCharset(charset, true)); + QByteArray best(QMailCodec::bestCompatibleCharset(charset, true)); + if (!best.isEmpty()) { + _type.setCharset(best); + } } } |