Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMAP: fix: backslash in password quoted string #378

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/java/davmail/imap/ImapConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -1847,10 +1847,6 @@ protected void parseCredentials(ImapTokenizer tokens) throws IOException {
} else {
throw new DavMailException("EXCEPTION_INVALID_CREDENTIALS");
}
int backslashindex = userName.indexOf('\\');
if (backslashindex > 0) {
userName = userName.substring(0, backslashindex) + userName.substring(backslashindex + 1);
}
}

/**
Expand Down Expand Up @@ -2121,7 +2117,19 @@ static class ImapTokenizer {
}

public String nextToken() {
return StringUtil.removeQuotes(nextQuotedToken());
// Note: despite method name, is not guaranteed to always produce a quoted token.
String token = nextQuotedToken();
// note: literal strings not handled here.
String ret;
if( !token.isEmpty() && '"' == token.charAt(0) ) {
// token is quoted string.
ret = StringUtil.parseQuotedImapString(token);
} else {
// use the general method previously also used;
// for example unquotes a list. I guess naming could be made better in the future.
ret = StringUtil.removeQuotes(token);
}
return ret;
}

protected boolean isQuote(char character) {
Expand Down
Loading