Fixed decoding of store URIs with empty passwords

This commit is contained in:
cketti 2011-10-18 05:05:40 +02:00
parent 9fa802afe2
commit dd8cd33c5a
2 changed files with 13 additions and 4 deletions

View File

@ -191,8 +191,14 @@ public class ImapStore extends Store {
if (imapUri.getUserInfo() != null) {
try {
String[] userInfoParts = imapUri.getUserInfo().split(":");
if (userInfoParts.length == 2) {
String userinfo = imapUri.getUserInfo();
String[] userInfoParts = userinfo.split(":");
if (userinfo.endsWith(":")) {
// Password is empty. This can only happen after an account was imported.
authenticationType = AuthType.valueOf(userInfoParts[0]).name();
username = URLDecoder.decode(userInfoParts[1], "UTF-8");
} else if (userInfoParts.length == 2) {
authenticationType = AuthType.PLAIN.name();
username = URLDecoder.decode(userInfoParts[0], "UTF-8");
password = URLDecoder.decode(userInfoParts[1], "UTF-8");

View File

@ -115,8 +115,11 @@ public class Pop3Store extends Store {
if (pop3Uri.getUserInfo() != null) {
try {
int userIndex = 0, passwordIndex = 1;
String[] userInfoParts = pop3Uri.getUserInfo().split(":");
if (userInfoParts.length > 2) {
String userinfo = pop3Uri.getUserInfo();
String[] userInfoParts = userinfo.split(":");
if (userInfoParts.length > 2 || userinfo.endsWith(":") ) {
// If 'userinfo' ends with ":" the password is empty. This can only happen
// after an account was imported (so authType and username are present).
userIndex++;
passwordIndex++;
authType = userInfoParts[0];