summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaman Tenneti <rtenneti@google.com>2019-05-31 10:52:02 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-05-31 10:52:02 -0700
commitf7005dabcddf646f3ff22685f12affbb91e5a6f0 (patch)
tree3e2b062ed4bbbd8eb3b6a4b2d26f6f973fda7602
parentad38b065750a25ff45bac3088c40867acd60610d (diff)
parentef35412cb61ad47d064936a0e69e59333c15eaea (diff)
downloadEmail-f7005dabcddf646f3ff22685f12affbb91e5a6f0.tar.gz
[automerger] AOSP/Email - bug fix: do not allow composing message with hidden private data attachments. am: e81f6f92bb am: 2f17f9f018 am: 34534259de am: 33587b4e1d am: 30a7c1118c
am: ef35412cb6 Change-Id: I60d7e7082c2c3a1980242815e247931ce4eaea19
-rw-r--r--src/com/android/email/activity/ComposeActivityEmailExternal.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/com/android/email/activity/ComposeActivityEmailExternal.java b/src/com/android/email/activity/ComposeActivityEmailExternal.java
index 455193bea..a5cbe9d3a 100644
--- a/src/com/android/email/activity/ComposeActivityEmailExternal.java
+++ b/src/com/android/email/activity/ComposeActivityEmailExternal.java
@@ -16,11 +16,21 @@
package com.android.email.activity;
+import android.content.Intent;
+import android.os.Bundle;
+import com.android.mail.compose.ComposeActivity;
+
/**
* A subclass of {@link ComposeActivityEmail} which is exported for other Android packages to open.
*/
public class ComposeActivityEmailExternal extends ComposeActivityEmail {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ sanitizeIntent();
+ super.onCreate(savedInstanceState);
+ }
+
/**
* Only relevant when WebView Compose is enabled. Change this when WebView
* Compose is enabled for Email.
@@ -29,4 +39,30 @@ public class ComposeActivityEmailExternal extends ComposeActivityEmail {
public boolean isExternal() {
return false;
}
+
+ /**
+ * Overrides the value of {@code #getIntent()} so any future callers will get a sanitized version
+ * of the intent.
+ */
+ // See b/114493057 for context.
+ private void sanitizeIntent() {
+ Intent sanitizedIntent = getIntent();
+ if (sanitizedIntent != null) {
+ Bundle originalExtras = sanitizedIntent.getExtras();
+ sanitizedIntent.replaceExtras(new Bundle());
+ copyStringExtraIfExists(ComposeActivity.EXTRA_SUBJECT, originalExtras, sanitizedIntent);
+ copyStringExtraIfExists(ComposeActivity.EXTRA_TO, originalExtras, sanitizedIntent);
+ copyStringExtraIfExists(ComposeActivity.EXTRA_CC, originalExtras, sanitizedIntent);
+ copyStringExtraIfExists(ComposeActivity.EXTRA_BCC, originalExtras, sanitizedIntent);
+ copyStringExtraIfExists(ComposeActivity.EXTRA_BODY, originalExtras, sanitizedIntent);
+ setIntent(sanitizedIntent);
+ }
+ }
+
+ private void copyStringExtraIfExists(
+ String extraKey, Bundle originalExtras, Intent sanitizedIntent) {
+ if (originalExtras.containsKey(extraKey)) {
+ sanitizedIntent.putExtra(extraKey, originalExtras.getString(extraKey));
+ }
+ }
}