am 9128217d: Merge forward small bug found in password storage

* commit '9128217da1f8ae53f1c44f369934ff075ae5057b':
  Merge forward small bug found in password storage
This commit is contained in:
Andy Stadler 2011-01-25 09:58:00 -08:00 committed by Android Git Automerger
commit 7ab349f971
2 changed files with 23 additions and 2 deletions

View File

@ -2683,8 +2683,8 @@ public abstract class EmailContent {
String userInfo = null;
if ((mFlags & FLAG_AUTHENTICATE) != 0) {
String trimUser = (mLogin != null) ? mLogin.trim() : "";
String trimPassword = (mPassword != null) ? mPassword.trim() : "";
userInfo = trimUser + ":" + trimPassword;
String password = (mPassword != null) ? mPassword : "";
userInfo = trimUser + ":" + password;
}
String address = (mAddress != null) ? mAddress.trim() : null;
String path = (mDomain != null) ? "/" + mDomain : null;

View File

@ -354,6 +354,27 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
assertEquals(587, ha.mPort);
}
/**
* Test preservation of username & password in URI
*/
@SuppressWarnings("deprecation")
public void testHostAuthUri() {
HostAuth ha = new HostAuth();
ha.setStoreUri("protocol://user:password@server:123");
String getUri = ha.getStoreUri();
assertEquals("protocol://user:password@server:123", getUri);
// Now put spaces in/around username (they are trimmed)
ha.setStoreUri("protocol://%20us%20er%20:password@server:123");
getUri = ha.getStoreUri();
assertEquals("protocol://us%20er:password@server:123", getUri);
// Now put spaces around password (should not be trimmed)
ha.setStoreUri("protocol://user:%20pass%20word%20@server:123");
getUri = ha.getStoreUri();
assertEquals("protocol://user:%20pass%20word%20@server:123", getUri);
}
/**
* Test simple mailbox save/retrieve
*/