andyedinborough / aenetmail

C# POP/IMAP Mail Client
369 stars 153 forks source link

spaces and double quotes in password #26

Closed AndyClaw closed 12 years ago

AndyClaw commented 12 years ago

If password contains a space, the login command sends too many arguments.

The answer is to put quotes around the password, and to handle quotes in the password use backslash to escape, and to handle backslash use double backslash. Per RFC 3501 section 9 Formal Syntax.

I recommend altering the login command found in internal override void OnLogin using the following line of code:

command = string.Format("{0}LOGIN {1} \"{2}\"", tag, login.Replace("\", "\").Replace("\"", "\""), password);

andyedinborough commented 12 years ago

The latest commit now makes sure the username and password are quoted in the login method.