diff --git a/src/com/fsck/k9/activity/setup/AccountSetupBasics.java b/src/com/fsck/k9/activity/setup/AccountSetupBasics.java index 0e3dcf020..56d409743 100644 --- a/src/com/fsck/k9/activity/setup/AccountSetupBasics.java +++ b/src/com/fsck/k9/activity/setup/AccountSetupBasics.java @@ -33,6 +33,7 @@ import com.fsck.k9.Preferences; import com.fsck.k9.R; import com.fsck.k9.activity.K9Activity; import com.fsck.k9.activity.setup.AccountSetupCheckSettings.CheckDirection; +import com.fsck.k9.helper.UrlEncodingHelper; import com.fsck.k9.helper.Utility; import com.fsck.k9.mail.AuthType; import com.fsck.k9.mail.ConnectionSecurity; @@ -279,8 +280,8 @@ public class AccountSetupBasics extends K9Activity URI incomingUri = null; URI outgoingUri = null; try { - String userEnc = com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(user); - String passwordEnc = com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(password); + String userEnc = UrlEncodingHelper.encodeUtf8(user); + String passwordEnc = UrlEncodingHelper.encodeUtf8(password); String incomingUsername = mProvider.incomingUsernameTemplate; incomingUsername = incomingUsername.replaceAll("\\$email", email); diff --git a/src/com/fsck/k9/mail/store/ImapStore.java b/src/com/fsck/k9/mail/store/ImapStore.java index bc524f6a9..13bf350af 100644 --- a/src/com/fsck/k9/mail/store/ImapStore.java +++ b/src/com/fsck/k9/mail/store/ImapStore.java @@ -62,6 +62,7 @@ import com.fsck.k9.K9; import com.fsck.k9.R; import com.fsck.k9.controller.MessageRetrievalListener; import com.fsck.k9.helper.StringUtils; +import com.fsck.k9.helper.UrlEncodingHelper; import com.fsck.k9.helper.Utility; import com.fsck.k9.helper.power.TracingPowerManager; import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock; @@ -202,19 +203,19 @@ public class ImapStore extends Store { if (userinfo.endsWith(":")) { // Password is empty. This can only happen after an account was imported. authenticationType = AuthType.valueOf(userInfoParts[0]); - username = com.fsck.k9.helper.UrlEncodingHelper.decodeUtf8(userInfoParts[1]); + username = UrlEncodingHelper.decodeUtf8(userInfoParts[1]); } else if (userInfoParts.length == 2) { authenticationType = AuthType.PLAIN; - username = com.fsck.k9.helper.UrlEncodingHelper.decodeUtf8(userInfoParts[0]); - password = com.fsck.k9.helper.UrlEncodingHelper.decodeUtf8(userInfoParts[1]); + username = UrlEncodingHelper.decodeUtf8(userInfoParts[0]); + password = UrlEncodingHelper.decodeUtf8(userInfoParts[1]); } else if (userInfoParts.length == 3) { authenticationType = AuthType.valueOf(userInfoParts[0]); - username = com.fsck.k9.helper.UrlEncodingHelper.decodeUtf8(userInfoParts[1]); + username = UrlEncodingHelper.decodeUtf8(userInfoParts[1]); if (AuthType.EXTERNAL == authenticationType) { - clientCertificateAlias = com.fsck.k9.helper.UrlEncodingHelper.decodeUtf8(userInfoParts[2]); + clientCertificateAlias = UrlEncodingHelper.decodeUtf8(userInfoParts[2]); } else { - password = com.fsck.k9.helper.UrlEncodingHelper.decodeUtf8(userInfoParts[2]); + password = UrlEncodingHelper.decodeUtf8(userInfoParts[2]); } } } @@ -253,11 +254,11 @@ public class ImapStore extends Store { * @see ImapStore#decodeUri(String) */ public static String createUri(ServerSettings server) { - String userEnc = com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(server.username); + String userEnc = UrlEncodingHelper.encodeUtf8(server.username); String passwordEnc = (server.password != null) ? - com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(server.password) : ""; + UrlEncodingHelper.encodeUtf8(server.password) : ""; String clientCertificateAliasEnc = (server.clientCertificateAlias != null) ? - com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(server.clientCertificateAlias) : ""; + UrlEncodingHelper.encodeUtf8(server.clientCertificateAlias) : ""; String scheme; switch (server.connectionSecurity) { diff --git a/src/com/fsck/k9/mail/store/Pop3Store.java b/src/com/fsck/k9/mail/store/Pop3Store.java index 6b3cf48fa..10d6f8231 100644 --- a/src/com/fsck/k9/mail/store/Pop3Store.java +++ b/src/com/fsck/k9/mail/store/Pop3Store.java @@ -7,6 +7,7 @@ import com.fsck.k9.Account; import com.fsck.k9.K9; import com.fsck.k9.R; import com.fsck.k9.controller.MessageRetrievalListener; +import com.fsck.k9.helper.UrlEncodingHelper; import com.fsck.k9.helper.Utility; import com.fsck.k9.mail.*; import com.fsck.k9.mail.filter.Base64; @@ -125,12 +126,12 @@ public class Pop3Store extends Store { passwordIndex++; authType = AuthType.valueOf(userInfoParts[0]); } - username = com.fsck.k9.helper.UrlEncodingHelper.decodeUtf8(userInfoParts[userIndex]); + username = UrlEncodingHelper.decodeUtf8(userInfoParts[userIndex]); if (userInfoParts.length > passwordIndex) { if (authType == AuthType.EXTERNAL) { - clientCertificateAlias = com.fsck.k9.helper.UrlEncodingHelper.decodeUtf8(userInfoParts[passwordIndex]); + clientCertificateAlias = UrlEncodingHelper.decodeUtf8(userInfoParts[passwordIndex]); } else { - password = com.fsck.k9.helper.UrlEncodingHelper.decodeUtf8(userInfoParts[passwordIndex]); + password = UrlEncodingHelper.decodeUtf8(userInfoParts[passwordIndex]); } } } @@ -151,11 +152,11 @@ public class Pop3Store extends Store { * @see Pop3Store#decodeUri(String) */ public static String createUri(ServerSettings server) { - String userEnc = com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(server.username); + String userEnc = UrlEncodingHelper.encodeUtf8(server.username); String passwordEnc = (server.password != null) ? - com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(server.password) : ""; + UrlEncodingHelper.encodeUtf8(server.password) : ""; String clientCertificateAliasEnc = (server.clientCertificateAlias != null) ? - com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(server.clientCertificateAlias) : ""; + UrlEncodingHelper.encodeUtf8(server.clientCertificateAlias) : ""; String scheme; switch (server.connectionSecurity) { diff --git a/src/com/fsck/k9/mail/store/WebDavStore.java b/src/com/fsck/k9/mail/store/WebDavStore.java index 5faca357f..1148927bb 100644 --- a/src/com/fsck/k9/mail/store/WebDavStore.java +++ b/src/com/fsck/k9/mail/store/WebDavStore.java @@ -5,6 +5,7 @@ import android.util.Log; import com.fsck.k9.Account; import com.fsck.k9.K9; import com.fsck.k9.controller.MessageRetrievalListener; + import com.fsck.k9.helper.UrlEncodingHelper; import com.fsck.k9.helper.Utility; import com.fsck.k9.mail.*; @@ -41,8 +42,6 @@ import javax.xml.parsers.SAXParserFactory; import java.io.*; import java.net.URI; import java.net.URISyntaxException; -import java.net.URLDecoder; -import java.net.URLEncoder; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import java.text.DateFormat; @@ -141,7 +140,7 @@ public class WebDavStore extends Store { String userInfo = webDavUri.getUserInfo(); if (userInfo != null) { String[] userInfoParts = userInfo.split(":"); - username = com.fsck.k9.helper.UrlEncodingHelper.decodeUtf8(userInfoParts[0]); + username = UrlEncodingHelper.decodeUtf8(userInfoParts[0]); String userParts[] = username.split("\\\\", 2); if (userParts.length > 1) { @@ -150,7 +149,7 @@ public class WebDavStore extends Store { alias = username; } if (userInfoParts.length > 1) { - password = com.fsck.k9.helper.UrlEncodingHelper.decodeUtf8(userInfoParts[1]); + password = UrlEncodingHelper.decodeUtf8(userInfoParts[1]); } } @@ -190,9 +189,9 @@ public class WebDavStore extends Store { * @see WebDavStore#decodeUri(String) */ public static String createUri(ServerSettings server) { - String userEnc = com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(server.username); + String userEnc = UrlEncodingHelper.encodeUtf8(server.username); String passwordEnc = (server.password != null) ? - com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(server.password) : ""; + UrlEncodingHelper.encodeUtf8(server.password) : ""; String scheme; switch (server.connectionSecurity) { @@ -1241,9 +1240,9 @@ public class WebDavStore extends Store { String url = ""; for (int i = 0, count = urlParts.length; i < count; i++) { if (i != 0) { - url = url + "/" + com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(urlParts[i]); + url = url + "/" + UrlEncodingHelper.encodeUtf8(urlParts[i]); } else { - url = com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(urlParts[i]); + url = UrlEncodingHelper.encodeUtf8(urlParts[i]); } } encodedName = url; @@ -1884,7 +1883,7 @@ public class WebDavStore extends Store { if (!messageURL.endsWith("/")) { messageURL += "/"; } - messageURL += com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(message.getUid() + ":" + System.currentTimeMillis() + ".eml"); + messageURL += UrlEncodingHelper.encodeUtf8(message.getUid() + ":" + System.currentTimeMillis() + ".eml"); Log.i(K9.LOG_TAG, "Uploading message as " + messageURL); @@ -1972,7 +1971,7 @@ public class WebDavStore extends Store { */ try { end = UrlEncodingHelper.decodeUtf8(end); - end = com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(end); + end = UrlEncodingHelper.encodeUtf8(end); end = end.replaceAll("\\+", "%20"); } catch (IllegalArgumentException iae) { Log.e(K9.LOG_TAG, "IllegalArgumentException caught in setUrl: " + iae + "\nTrace: " @@ -2377,7 +2376,7 @@ public class WebDavStore extends Store { try { if (length > 3) { end = UrlEncodingHelper.decodeUtf8(end); - end = com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(end); + end = UrlEncodingHelper.encodeUtf8(end); end = end.replaceAll("\\+", "%20"); } } catch (IllegalArgumentException iae) { diff --git a/src/com/fsck/k9/mail/store/local/LocalStore.java b/src/com/fsck/k9/mail/store/local/LocalStore.java index 0591fe253..e200ae087 100644 --- a/src/com/fsck/k9/mail/store/local/LocalStore.java +++ b/src/com/fsck/k9/mail/store/local/LocalStore.java @@ -26,6 +26,7 @@ import com.fsck.k9.K9; import com.fsck.k9.Preferences; import com.fsck.k9.controller.MessageRetrievalListener; import com.fsck.k9.helper.StringUtils; +import com.fsck.k9.helper.UrlEncodingHelper; import com.fsck.k9.helper.Utility; import com.fsck.k9.mail.Flag; import com.fsck.k9.mail.Folder; @@ -467,7 +468,7 @@ public class LocalStore extends Store implements Serializable { public void addPendingCommand(PendingCommand command) throws UnavailableStorageException { for (int i = 0; i < command.arguments.length; i++) { - command.arguments[i] = com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(command.arguments[i]); + command.arguments[i] = UrlEncodingHelper.encodeUtf8(command.arguments[i]); } final ContentValues cv = new ContentValues(); cv.put("command", command.command); diff --git a/src/com/fsck/k9/mail/transport/SmtpTransport.java b/src/com/fsck/k9/mail/transport/SmtpTransport.java index f90d1999b..5d68104af 100644 --- a/src/com/fsck/k9/mail/transport/SmtpTransport.java +++ b/src/com/fsck/k9/mail/transport/SmtpTransport.java @@ -6,6 +6,7 @@ import android.util.Log; import com.fsck.k9.Account; import com.fsck.k9.K9; import com.fsck.k9.R; +import com.fsck.k9.helper.UrlEncodingHelper; import com.fsck.k9.helper.Utility; import com.fsck.k9.mail.*; import com.fsck.k9.mail.Message.RecipientType; @@ -94,19 +95,19 @@ public class SmtpTransport extends Transport { String[] userInfoParts = smtpUri.getUserInfo().split(":"); if (userInfoParts.length == 1) { authType = AuthType.PLAIN; - username = com.fsck.k9.helper.UrlEncodingHelper.decodeUtf8(userInfoParts[0]); + username = UrlEncodingHelper.decodeUtf8(userInfoParts[0]); } else if (userInfoParts.length == 2) { authType = AuthType.PLAIN; - username = com.fsck.k9.helper.UrlEncodingHelper.decodeUtf8(userInfoParts[0]); - password = com.fsck.k9.helper.UrlEncodingHelper.decodeUtf8(userInfoParts[1]); + username = UrlEncodingHelper.decodeUtf8(userInfoParts[0]); + password = UrlEncodingHelper.decodeUtf8(userInfoParts[1]); } else if (userInfoParts.length == 3) { // NOTE: In SmptTransport URIs, the authType comes last! authType = AuthType.valueOf(userInfoParts[2]); - username = com.fsck.k9.helper.UrlEncodingHelper.decodeUtf8(userInfoParts[0]); + username = UrlEncodingHelper.decodeUtf8(userInfoParts[0]); if (authType == AuthType.EXTERNAL) { - clientCertificateAlias = com.fsck.k9.helper.UrlEncodingHelper.decodeUtf8(userInfoParts[1]); + clientCertificateAlias = UrlEncodingHelper.decodeUtf8(userInfoParts[1]); } else { - password = com.fsck.k9.helper.UrlEncodingHelper.decodeUtf8(userInfoParts[1]); + password = UrlEncodingHelper.decodeUtf8(userInfoParts[1]); } } } @@ -128,11 +129,11 @@ public class SmtpTransport extends Transport { */ public static String createUri(ServerSettings server) { String userEnc = (server.username != null) ? - com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(server.username) : ""; + UrlEncodingHelper.encodeUtf8(server.username) : ""; String passwordEnc = (server.password != null) ? - com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(server.password) : ""; + UrlEncodingHelper.encodeUtf8(server.password) : ""; String clientCertificateAliasEnc = (server.clientCertificateAlias != null) ? - com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(server.clientCertificateAlias) : ""; + UrlEncodingHelper.encodeUtf8(server.clientCertificateAlias) : ""; String scheme; switch (server.connectionSecurity) { diff --git a/src/com/fsck/k9/preferences/Storage.java b/src/com/fsck/k9/preferences/Storage.java index 84f542d5a..e88a9b6c3 100644 --- a/src/com/fsck/k9/preferences/Storage.java +++ b/src/com/fsck/k9/preferences/Storage.java @@ -9,6 +9,7 @@ import android.database.sqlite.SQLiteStatement; import android.util.Log; import com.fsck.k9.K9; +import com.fsck.k9.helper.UrlEncodingHelper; import com.fsck.k9.helper.Utility; import java.net.URI; @@ -59,11 +60,11 @@ public class Storage implements SharedPreferences { if (transportUriStr != null) { String[] userInfoParts = uri.getUserInfo().split(":"); - String usernameEnc = com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(userInfoParts[0]); + String usernameEnc = UrlEncodingHelper.encodeUtf8(userInfoParts[0]); String passwordEnc = ""; String authType = ""; if (userInfoParts.length > 1) { - passwordEnc = ":" + com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(userInfoParts[1]); + passwordEnc = ":" + UrlEncodingHelper.encodeUtf8(userInfoParts[1]); } if (userInfoParts.length > 2) { authType = ":" + userInfoParts[2]; @@ -83,34 +84,34 @@ public class Storage implements SharedPreferences { if (storeUriStr.startsWith("imap")) { String[] userInfoParts = uri.getUserInfo().split(":"); if (userInfoParts.length == 2) { - String usernameEnc = com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(userInfoParts[0]); - String passwordEnc = com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(userInfoParts[1]); + String usernameEnc = UrlEncodingHelper.encodeUtf8(userInfoParts[0]); + String passwordEnc = UrlEncodingHelper.encodeUtf8(userInfoParts[1]); newUserInfo = usernameEnc + ":" + passwordEnc; } else { String authType = userInfoParts[0]; - String usernameEnc = com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(userInfoParts[1]); - String passwordEnc = com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(userInfoParts[2]); + String usernameEnc = UrlEncodingHelper.encodeUtf8(userInfoParts[1]); + String passwordEnc = UrlEncodingHelper.encodeUtf8(userInfoParts[2]); newUserInfo = authType + ":" + usernameEnc + ":" + passwordEnc; } } else if (storeUriStr.startsWith("pop3")) { String[] userInfoParts = uri.getUserInfo().split(":", 2); - String usernameEnc = com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(userInfoParts[0]); + String usernameEnc = UrlEncodingHelper.encodeUtf8(userInfoParts[0]); String passwordEnc = ""; if (userInfoParts.length > 1) { - passwordEnc = ":" + com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(userInfoParts[1]); + passwordEnc = ":" + UrlEncodingHelper.encodeUtf8(userInfoParts[1]); } newUserInfo = usernameEnc + passwordEnc; } else if (storeUriStr.startsWith("webdav")) { String[] userInfoParts = uri.getUserInfo().split(":", 2); - String usernameEnc = com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(userInfoParts[0]); + String usernameEnc = UrlEncodingHelper.encodeUtf8(userInfoParts[0]); String passwordEnc = ""; if (userInfoParts.length > 1) { - passwordEnc = ":" + com.fsck.k9.helper.UrlEncodingHelper.encodeUtf8(userInfoParts[1]); + passwordEnc = ":" + UrlEncodingHelper.encodeUtf8(userInfoParts[1]); } newUserInfo = usernameEnc + passwordEnc; diff --git a/src/com/fsck/k9/view/SingleMessageView.java b/src/com/fsck/k9/view/SingleMessageView.java index a7407ca4f..bca3eef0d 100644 --- a/src/com/fsck/k9/view/SingleMessageView.java +++ b/src/com/fsck/k9/view/SingleMessageView.java @@ -47,6 +47,7 @@ import com.fsck.k9.fragment.MessageViewFragment; import com.fsck.k9.helper.ClipboardManager; import com.fsck.k9.helper.Contacts; import com.fsck.k9.helper.HtmlConverter; +import com.fsck.k9.helper.UrlEncodingHelper; import com.fsck.k9.helper.Utility; import com.fsck.k9.mail.Address; import com.fsck.k9.mail.Flag; @@ -790,7 +791,7 @@ public class SingleMessageView extends LinearLayout implements OnClickListener, // Try to get the filename from the URL int start = path.lastIndexOf("/"); if (start != -1 && start + 1 < path.length()) { - filename = com.fsck.k9.helper.UrlEncodingHelper.decodeUtf8(path.substring(start + 1)); + filename = UrlEncodingHelper.decodeUtf8(path.substring(start + 1)); } else { // Use a dummy filename if necessary filename = "saved_image";