From 542e0c085e48d241312ad6ac4877de1c0ca0f6f9 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Fri, 16 Sep 2011 21:56:05 +0200 Subject: [PATCH] Support imap passwords with strange characters (sf.net #3402448) conky now sends the password using the length + string format, which should not need any quoting of special characters. Hopefully, we won't find a server which does not support this encoding. This also fixes a bug which prevented the password from being entered from the console. bug reported by Brent --- src/mail.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/mail.cc b/src/mail.cc index 6786f9f4..e7208f76 100644 --- a/src/mail.cc +++ b/src/mail.cc @@ -55,6 +55,7 @@ #include #include +#include #include "update-cb.hh" @@ -536,7 +537,7 @@ std::unique_ptr parse_mail_args(mail_type type, const char *arg) term.c_lflag &= ~ECHO; tcsetattr(fp, TCSANOW, &term); printf("Enter mailbox password (%s@%s): ", user, host); - if (scanf("%128s", pass)) + if (scanf("%128s", pass) != 1) pass[0] = 0; printf("\n"); term.c_lflag |= ECHO; @@ -775,8 +776,11 @@ void imap_cb::work() if (strstr(recvbuf, " IDLE ") != NULL) has_idle = true; - command(sockfd, "a1 login " + get() + " " + get() + "\r\n", - recvbuf, "a1 OK"); + std::ostringstream str; + str << "a1 login " << get() << " {" << get().length() << "}\r\n"; + command(sockfd, str.str(), recvbuf, "+ OK"); + + command(sockfd, get() + "\r\n", recvbuf, "a1 OK"); command(sockfd, "a2 STATUS \"" + get() + "\" (MESSAGES UNSEEN)\r\n", recvbuf, "a2 OK");