fix: accept Intent.EXTRA_EMAIL as String or String[] - #256
Open
xhon-pelushi wants to merge 1 commit into
Open
Conversation
Intent.EXTRA_EMAIL is documented as a String[] of e-mail addresses, but LaunchConversationActivity and ShareIntentActivity read it with getStringExtra(), which silently returns null for the array extras put by well-behaved senders (including this app's own VCardDetailEffectHandler, which already puts EXTRA_EMAIL as a String[]). Use getStringArrayExtra() so intents carrying the extra in its documented type are handled, and forward every address rather than only the first one. Fixes GrapheneOS#164
RankoR
suggested changes
Aug 17, 2026
RankoR
left a comment
Contributor
There was a problem hiding this comment.
Thanks for your contribution!
- Added/changed code should be covered by tests
- PR title states that both String and String[] now accepted, but in the code you're retrieving only array.
| } | ||
| final boolean haveAddress = !TextUtils.isEmpty(intent.getStringExtra(ADDRESS)); | ||
| final boolean haveEmail = !TextUtils.isEmpty(intent.getStringExtra(Intent.EXTRA_EMAIL)); | ||
| final String[] emails = intent.getStringArrayExtra(Intent.EXTRA_EMAIL); |
Contributor
There was a problem hiding this comment.
Array items are not guaranteed to be non-null.
LaunchConversationActivity.java:113-119:
for (String recipient : recipients) {
if (recipient.length() < MAX_RECIPIENT_LENGTH) { // Will crash here
So, it should also be fixed in LaunchConversationActivity.java:113-119:
for (String recipient : recipients) {
if (!TextUtils.isEmpty(recipient) && recipient.length() < MAX_RECIPIENT_LENGTH) {
Same for ShareIntentActivity
| intent.getStringExtra(Intent.EXTRA_EMAIL).isNullOrEmpty() | ||
| intent.getStringArrayExtra(Intent.EXTRA_EMAIL).isNullOrEmpty() | ||
|
|
||
| if (Intent.ACTION_SEND != intent.action || hasNoDestination) { |
Contributor
There was a problem hiding this comment.
Perhaps should become Intent.ACTION_SEND != intent.action || hasNoDestination || intent.hasExtra(Intent.EXTRA_STREAM), otherwise for EXTRA_STREAM + EXTRA_EMAIL intents we're losing EXTRA_STREAM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Handle EXTRA_EMAIL when callers pass a single String instead of String[].
Fixes #164
Test plan