Application of patch submitted by cnehren for Issue 356, with

generalization.
This commit is contained in:
Daniel Applebaum 2009-04-11 15:24:22 +00:00
parent 932adf5ed2
commit aa4a92a541

View file

@ -1299,7 +1299,7 @@ public class ImapStore extends Store {
try {
// TODO eventually we need to add additional authentication
// options such as SASL
executeSimpleCommand("LOGIN \"" + mUsername + "\" \"" + mPassword + "\"", true);
executeSimpleCommand("LOGIN \"" + escapeString(mUsername) + "\" \"" + escapeString(mPassword) + "\"", true);
authSuccess = true;
} catch (ImapException ie) {
throw new AuthenticationFailedException(ie.getAlertText(), ie);
@ -1380,6 +1380,17 @@ public class ImapStore extends Store {
throw ioe;
}
}
private String escapeString(String in)
{
if (in == null)
{
return null;
}
String out = in.replaceAll("\\\\", "\\\\\\\\");
out = out.replaceAll("\"", "\\\\\"");
return out;
}
public String sendCommand(String command, boolean sensitive)
throws MessagingException, IOException {