mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 03:32:16 -05:00
Fix IMAP uri decode when user/pw contains ':'
This commit is contained in:
parent
7752f42db6
commit
8194c20ffe
@ -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]);
|
||||
|
@ -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<String, String> extra = new HashMap<String, String>();
|
||||
|
Loading…
Reference in New Issue
Block a user