Skip to content

Commit

Permalink
Merge pull request #21 from nemomobile-packages/smtp-improvement
Browse files Browse the repository at this point in the history
[qmf] Make SMTP AUTH PLAIN more robust.
  • Loading branch information
VDVsx committed Jan 15, 2014
2 parents e6bcb44 + 9710622 commit 1885109
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions qmf/src/plugins/messageservices/smtp/smtpauthenticator.cpp
Expand Up @@ -63,10 +63,10 @@ QByteArray SmtpAuthenticator::getAuthentication(const QMailAccountConfiguration:
SmtpConfiguration smtpCfg(svcCfg);
if (smtpCfg.smtpAuthentication() != SmtpConfiguration::Auth_NONE) {
QMailAccountId id(smtpCfg.id());
QByteArray username(smtpCfg.smtpUsername().toLatin1());
QByteArray username(smtpCfg.smtpUsername().toUtf8());
QByteArray pass;
if (ssoLogin.isEmpty()) {
pass = smtpCfg.smtpPassword().toLatin1();
pass = smtpCfg.smtpPassword().toUtf8();
qMailLog(SMTP) << Q_FUNC_INFO << "SSO identity is not found for account id: "<< id
<< ", using password from accounts configuration";
} else {
Expand All @@ -80,7 +80,7 @@ QByteArray SmtpAuthenticator::getAuthentication(const QMailAccountConfiguration:
result = QByteArray("LOGIN");
gResponses[id] = (QList<QByteArray>() << username << pass);
} else if (smtpCfg.smtpAuthentication() == SmtpConfiguration::Auth_PLAIN) {
result = QByteArray("PLAIN");
result = QByteArray("PLAIN ") + QByteArray(username + '\0' + username + '\0' + pass).toBase64();
gResponses[id] = (QList<QByteArray>() << QByteArray(username + '\0' + username + '\0' + pass));
}
}
Expand Down Expand Up @@ -123,8 +123,8 @@ QByteArray SmtpAuthenticator::getAuthentication(const QMailAccountConfiguration:
SmtpConfiguration smtpCfg(svcCfg);
if (smtpCfg.smtpAuthentication() != SmtpConfiguration::Auth_NONE) {
QMailAccountId id(smtpCfg.id());
QByteArray username(smtpCfg.smtpUsername().toLatin1());
QByteArray password(smtpCfg.smtpPassword().toLatin1());
QByteArray username(smtpCfg.smtpUsername().toUtf8());
QByteArray password(smtpCfg.smtpPassword().toUtf8());

if (smtpCfg.smtpAuthentication() == SmtpConfiguration::Auth_LOGIN) {
result = QByteArray("LOGIN");
Expand Down
6 changes: 3 additions & 3 deletions qmf/src/plugins/ssoauth/password/passwordplugin.cpp
Expand Up @@ -121,15 +121,15 @@ QList<QByteArray> SSOPasswordPlugin::getSMTPAuthentication(const QString &passwo
const QString &username, int serviceAuthentication) const
{
QList<QByteArray> result;
QByteArray user(username.toLatin1());
QByteArray pass(password.toLatin1());
QByteArray user(username.toUtf8());
QByteArray pass(password.toUtf8());

if (serviceAuthentication == QMail::LoginMechanism) {
result.append(QByteArray("AUTH LOGIN"));
result.append(QByteArray(user));
result.append(QByteArray(pass));
} else if (serviceAuthentication == QMail::PlainMechanism) {
result.append(QByteArray("AUTH PLAIN"));
result.append(QByteArray("AUTH PLAIN ") + QByteArray(user + '\0' + user + '\0' + pass).toBase64());
result.append(QByteArray(user + '\0' + user + '\0' + pass));
} else if (serviceAuthentication == QMail::CramMd5Mechanism) {
result.append(QByteArray(pass));
Expand Down

0 comments on commit 1885109

Please sign in to comment.