aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJake Klinker <jklinker@google.com>2023-05-11 21:32:48 +0000
committerJake Klinker <jklinker@google.com>2023-05-11 21:59:23 +0000
commite37bb58fbb38fdf6bb69f2ee379138b2c4559598 (patch)
tree5370af94762d11e38421578dcce80fa8f3b670b7
parent0d5452146c58aa9b938daffc88f8b03eb9aee58b (diff)
downloadMessaging-e37bb58fbb38fdf6bb69f2ee379138b2c4559598.tar.gz
Trim recipient addresses that are unreasonably long.
This ensures that bad input does not affect the db - the fallback is a reasonable one where we just launch the new conversation screen and have the user select the recipient. TESTED=manually confirmed that I could no longer repro b/278556945 after this change. BUG=278556945 Change-Id: I705a304a92cb46b20d916c6f5c2db81e6fa84f06
-rw-r--r--src/com/android/messaging/ui/conversation/LaunchConversationActivity.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/com/android/messaging/ui/conversation/LaunchConversationActivity.java b/src/com/android/messaging/ui/conversation/LaunchConversationActivity.java
index 5500ae8..c869839 100644
--- a/src/com/android/messaging/ui/conversation/LaunchConversationActivity.java
+++ b/src/com/android/messaging/ui/conversation/LaunchConversationActivity.java
@@ -37,6 +37,8 @@ import com.android.messaging.util.UriUtil;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.List;
/**
* Launches ConversationActivity for sending a message to, or viewing messages from, a specific
@@ -46,6 +48,7 @@ import java.net.URLDecoder;
*/
public class LaunchConversationActivity extends Activity implements
LaunchConversationData.LaunchConversationDataListener {
+ private static final int MAX_RECIPIENT_LENGTH = 100;
static final String SMS_BODY = "sms_body";
static final String ADDRESS = "address";
final Binding<LaunchConversationData> mBinding = BindingBase.createBinding(this);
@@ -76,6 +79,9 @@ public class LaunchConversationActivity extends Activity implements
recipients = new String[] { intent.getStringExtra(Intent.EXTRA_EMAIL) };
}
}
+ if (recipients != null) {
+ recipients = trimInvalidRecipients(recipients);
+ }
mSmsBody = intent.getStringExtra(SMS_BODY);
if (TextUtils.isEmpty(mSmsBody)) {
// Used by intents sent from the web YouTube (and perhaps others).
@@ -103,6 +109,20 @@ public class LaunchConversationActivity extends Activity implements
finish();
}
+ private String[] trimInvalidRecipients(String[] recipients) {
+ List<String> trimmedRecipients = new ArrayList<>();
+ for (String recipient : recipients) {
+ if (recipient.length() < MAX_RECIPIENT_LENGTH) {
+ trimmedRecipients.add(recipient);
+ }
+ }
+ if (trimmedRecipients.size() > 0) {
+ return trimmedRecipients.toArray(new String[0]);
+ } else {
+ return null;
+ }
+ }
+
private String getBody(final Uri uri) {
if (uri == null) {
return null;