1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00

Fix IMAP uri decode when user/pw contains ':'

This commit is contained in:
Jan Berkel 2014-12-21 11:52:05 +01:00
parent 7752f42db6
commit 8194c20ffe
2 changed files with 13 additions and 5 deletions

View File

@ -159,11 +159,10 @@ public class ImapStore extends RemoteStore {
port = imapUri.getPort(); port = imapUri.getPort();
} }
if (imapUri.getUserInfo() != null) { final String userInfo = imapUri.getRawUserInfo();
String userinfo = imapUri.getUserInfo(); if (userInfo != null) {
String[] userInfoParts = userinfo.split(":"); String[] userInfoParts = userInfo.split(":");
if (userInfo.endsWith(":")) {
if (userinfo.endsWith(":")) {
// Password is empty. This can only happen after an account was imported. // Password is empty. This can only happen after an account was imported.
authenticationType = AuthType.valueOf(userInfoParts[0]); authenticationType = AuthType.valueOf(userInfoParts[0]);
username = decodeUtf8(userInfoParts[1]); username = decodeUtf8(userInfoParts[1]);

View File

@ -78,6 +78,15 @@ public class ImapStoreUriTest {
assertNull(settings.getExtra().get("pathPrefix")); 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() { @Test public void testCreateStoreUriImapPrefix() {
Map<String, String> extra = new HashMap<String, String>(); Map<String, String> extra = new HashMap<String, String>();