From kde-commits Fri Jan 19 13:57:42 2007 From: Tom Albers Date: Fri, 19 Jan 2007 13:57:42 +0000 To: kde-commits Subject: playground/pim/mailody/src Message-Id: <1169215062.467332.8756.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=116921508405956 SVN commit 625208 by toma: Quote login and password. Please check if it works, there is nothing in the IMAP rfc about this. Copied KDE kioslave behaviour, so should be ok. BUG: 140291 M +22 -3 imap.cpp M +1 -0 imap.h --- trunk/playground/pim/mailody/src/imap.cpp #625207:625208 @@ -95,7 +95,8 @@ else { m_queue.prepend(Queue(Queue::Auth, "", - "login \"" + login + "\" \"" + pass + "\"")); + "login \"" + quoteIMAP(login) + + "\" \"" + quoteIMAP(pass) + "\"")); m_currentQueueItem=Queue(); emit statusReady(); @@ -125,8 +126,8 @@ } if (result == KPasswordDialog::Accepted) m_queue.prepend(Queue(Queue::Auth, "", - "login \"" + login + "\" \"" + - QString(password) + "\"")); + "login \"" + quoteIMAP(login) + "\" \"" + + quoteIMAP(QString(password)) + "\"")); password.fill(0); // safe enough? m_currentQueueItem=Queue(); emit statusReady(); @@ -1145,6 +1146,24 @@ m_imap->reconnect(); } +/* Copy from KDE/3.5/kdepim/kioslaves/imap4/rfcdecoder.cc */ +/* Copyright (C) 2000 s.carstens@gmx.de */ +/* replace " with \" and \ with \\ " and \ characters */ +QString Imap::quoteIMAP(const QString &src) +{ + uint len = src.length(); + QString result; + result.reserve(2 * len); + for (unsigned int i = 0; i < len; i++) + { + if (src[i] == '"' || src[i] == '\\') + result += '\\'; + result += src[i]; + } + //result.squeeze(); - unnecessary and slow + return result; } +} + #include "imap.moc" --- trunk/playground/pim/mailody/src/imap.h #625207:625208 @@ -232,6 +232,7 @@ void integrity(const QString& mb, int); void timerEvent( QTimerEvent * ); void getCapabilities(); + QString quoteIMAP(const QString &src); signals: /**