[automerge] Trim recipient addresses that are unreasonably long. 2p: e37bb58fbb 2p: 22ba5f1d3d am: dd2620769f
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Messaging/+/23181897 Change-Id: Ic9adc8cb2b80e71d0a5234447c2447471fcab633 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
committed by
Automerger Merge Worker
commit
f4ef062dc2
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user