1
0
mirror of https://github.com/moparisthebest/k-9 synced 2025-01-12 14:18:02 -05:00

Don't log sensitive information in SMTP commands when "Log sensitive

information" is unchecked. Applied patch by fiouzy with some small modifications.

Fixes issue 1387
This commit is contained in:
cketti 2010-06-02 13:14:30 +00:00
parent 34a95ba006
commit 64c7df60ab

View File

@ -415,10 +415,21 @@ public class SmtpTransport extends Transport
return ret;
}
private void writeLine(String s) throws IOException
private void writeLine(String s, boolean sensitive) throws IOException
{
if (K9.DEBUG)
Log.d(K9.LOG_TAG, "SMTP >>> " + s);
{
final String commandToLog;
if (sensitive && !K9.DEBUG_SENSITIVE)
{
commandToLog = "SMTP >>> *sensitive*";
}
else
{
commandToLog = "SMTP >>> " + s;
}
Log.d(K9.LOG_TAG, commandToLog);
}
/*
* Note: We can use the string length to compute the buffer size since
@ -455,11 +466,17 @@ public class SmtpTransport extends Transport
}
private List<String> executeSimpleCommand(String command) throws IOException, MessagingException
{
return executeSimpleCommand(command, false);
}
private List<String> executeSimpleCommand(String command, boolean sensitive)
throws IOException, MessagingException
{
List<String> results = new ArrayList<String>();
if (command != null)
{
writeLine(command);
writeLine(command, sensitive);
}
boolean cont = false;
@ -509,8 +526,8 @@ public class SmtpTransport extends Transport
try
{
executeSimpleCommand("AUTH LOGIN");
executeSimpleCommand(new String(Base64.encodeBase64(username.getBytes())));
executeSimpleCommand(new String(Base64.encodeBase64(password.getBytes())));
executeSimpleCommand(new String(Base64.encodeBase64(username.getBytes())), true);
executeSimpleCommand(new String(Base64.encodeBase64(password.getBytes())), true);
}
catch (MessagingException me)
{
@ -530,7 +547,7 @@ public class SmtpTransport extends Transport
data = new Base64().encode(data);
try
{
executeSimpleCommand("AUTH PLAIN " + new String(data));
executeSimpleCommand("AUTH PLAIN " + new String(data), true);
}
catch (MessagingException me)
{
@ -579,7 +596,7 @@ public class SmtpTransport extends Transport
String b64CRAMString = new String(b64CRAM, "US-ASCII");
try
{
executeSimpleCommand(b64CRAMString);
executeSimpleCommand(b64CRAMString, true);
}
catch (MessagingException me)
{