Keep the IMAP password out of error messages
A refused IMAP command's error quoted the whole command, so a failed
LOGIN put the password into the log on every sync. The error now names
only the verb ("IMAP LOGIN failed: ..."). Carried over from web_server's
backend, which logged it the same way.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -120,7 +120,10 @@ func (c *imapClient) sendCommandOK(cmd string) ([]string, error) {
|
||||
// "<tag> BAD ..." otherwise; only the second field matters.
|
||||
parts := strings.SplitN(status, " ", 3)
|
||||
if len(parts) < 2 || parts[1] != "OK" {
|
||||
return untagged, fmt.Errorf("command %q failed: %s", cmd, status)
|
||||
// Only the verb, never the whole command: a failed LOGIN carries the
|
||||
// password, and this error goes to the log.
|
||||
verb, _, _ := strings.Cut(cmd, " ")
|
||||
return untagged, fmt.Errorf("IMAP %s failed: %s", verb, status)
|
||||
}
|
||||
return untagged, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user