| Summary: | Imap password should be properly escaped | ||
|---|---|---|---|
| Product: | [Unmaintained] mailody | Reporter: | Tommi Tervo <tommi.tervo> |
| Component: | general | Assignee: | Tom Albers <toma> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | unspecified | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Tommi Tervo
2007-01-19 14:34:17 UTC
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:
/**
Confirmed, fix works fine |