diff --git a/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapStore.java b/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapStore.java index f0959b4b0..dfa7fbb75 100644 --- a/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapStore.java +++ b/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapStore.java @@ -159,11 +159,10 @@ public class ImapStore extends RemoteStore { port = imapUri.getPort(); } - if (imapUri.getUserInfo() != null) { - String userinfo = imapUri.getUserInfo(); - String[] userInfoParts = userinfo.split(":"); - - if (userinfo.endsWith(":")) { + final String userInfo = imapUri.getRawUserInfo(); + if (userInfo != null) { + String[] userInfoParts = userInfo.split(":"); + if (userInfo.endsWith(":")) { // Password is empty. This can only happen after an account was imported. authenticationType = AuthType.valueOf(userInfoParts[0]); username = decodeUtf8(userInfoParts[1]); diff --git a/tests-on-jvm/src/test/java/com/fsck/k9/mail/store/imap/ImapStoreUriTest.java b/tests-on-jvm/src/test/java/com/fsck/k9/mail/store/imap/ImapStoreUriTest.java index 49507de36..96c3783c7 100644 --- a/tests-on-jvm/src/test/java/com/fsck/k9/mail/store/imap/ImapStoreUriTest.java +++ b/tests-on-jvm/src/test/java/com/fsck/k9/mail/store/imap/ImapStoreUriTest.java @@ -78,6 +78,15 @@ public class ImapStoreUriTest { assertNull(settings.getExtra().get("pathPrefix")); } + @Test public void testDecodeStoreUriWithColonsInUsernameAndPassword() { + String uri = "imap://PLAIN:a%3Auser:password%3Ahas%3Acolons@foo.com:993"; + ServerSettings settings = RemoteStore.decodeStoreUri(uri); + assertEquals(AuthType.PLAIN, settings.authenticationType); + assertEquals("a:user", settings.username); + assertEquals("password:has:colons", settings.password); + assertEquals("foo.com", settings.host); + assertEquals(993, settings.port); + } @Test public void testCreateStoreUriImapPrefix() { Map extra = new HashMap();