Skip to content

Share a file whose mime type is not one of the supported ones - #7435

Open
hayaksi1 wants to merge 2 commits into
element-hq:developfrom
hayaksi1:fix/5623-share-unlisted-mime-type
Open

Share a file whose mime type is not one of the supported ones#7435
hayaksi1 wants to merge 2 commits into
element-hq:developfrom
hayaksi1:fix/5623-share-unlisted-mime-type

Conversation

@hayaksi1

Copy link
Copy Markdown
Contributor

Content

DefaultShareIntentHandler.handleIncomingShareIntent only accepted an intent whose resolved mime
type started with image/, video/, audio/, application/, file/, text/ or */. An
ACTION_SEND carrying EXTRA_STREAM with any other top level type fell through to null, and
IntentResolver drops the intent, so nothing happened when sharing into the app.

The uris are already extracted before that check, so their presence is enough to know the intent
carries something to send. The mime type list is kept for the case where there are no uris, so no
currently accepted intent is affected.

Motivation and context

Fixes #5623. The reporter shares a .zip from Tasks, which sends it as message/rfc822. The
manifest filter for the share target is */*, so the app advertises that it accepts this and then
silently discards it.

Tests

  • ./gradlew :features:share:impl:testDebugUnitTest
  • New DefaultShareIntentHandlerTest covers an unlisted mime type with one uri, with several uris,
    with an EXTRA_TEXT caption, plus the image, plain text and nothing-to-share cases. The three
    unlisted-mime-type tests fail without the change.

Tested devices

  • Physical
  • Emulator
  • OS version(s):

handleIncomingShareIntent only accepted an intent whose resolved mime type
started with image/, video/, audio/, application/, file/, text/ or */. An
ACTION_SEND carrying EXTRA_STREAM with any other top level type, such as the
message/rfc822 that some apps use when attaching a file, fell through to null
and the share was dropped before the room picker ever appeared, even though
the manifest filter accepts */*.

The uris are extracted before that check, so their presence is enough to know
the intent carries something to send. Accept the intent when it has uris and
keep the mime type list for the case where it does not.
@hayaksi1
hayaksi1 requested a review from a team as a code owner August 16, 2026 19:45
@hayaksi1
hayaksi1 requested review from bmarty and removed request for a team August 16, 2026 19:45
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Here are a few things to check in the PR to ensure it's reviewed as quickly as possible:

  • If your pull request adds a feature or modifies the UI, this should have an equivalent pull request in the Element X iOS repo unless it only affects an Android-only behaviour or is behind a disabled feature flag, since we need parity in both clients to consider a feature done. It will also need to be approved by our product and design teams before being merged, so it's usually a good idea to discuss the changes in a Github issue first and then start working on them once the approach has been validated.
  • Your branch should be based on origin/develop, at least when it was created.
  • The title of the PR will be used for release notes, so it needs to describe the change visible to the user.
  • The test pass locally running ./gradlew test.
  • The code quality check suite pass locally running ./gradlew runQualityChecks.
  • If you modified anything related to the UI, including previews, you'll have to run the Record screenshots GH action in your forked repo: that will generate compatible new screenshots. However, given Github Actions limitations, it will prevent the CI from running temporarily, until you upload a new commit after that one. To do so, just pull the latest changes and push an empty commit.

@github-actions github-actions Bot added the Z-Community-PR Issue is solved by a community member's PR label Aug 16, 2026

@bmarty bmarty left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks!

@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.69%. Comparing base (23b75c3) to head (8e02f03).
⚠️ Report is 31 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #7435      +/-   ##
===========================================
+ Coverage    80.65%   80.69%   +0.04%     
===========================================
  Files         2772     2772              
  Lines        80803    80804       +1     
  Branches     11053    11054       +1     
===========================================
+ Hits         65168    65203      +35     
+ Misses       11370    11336      -34     
  Partials      4265     4265              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

An intent carrying uris is now accepted before the mime type list is
reached, so the image check that every uri share used to exercise is only
covered by an intent which has nothing to send. Add one case per listed
mime type without a uri.

Cover the rest of the handler while it is under test: an intent with no
resolvable type, a send multiple without a stream, an action which is
neither send nor send multiple, an empty caption, a plain text intent
without text, the mime type reported by the content resolver for the uri,
and the explicit intent built for the application which will read it, both
when the read permission can be granted and when it cannot.
@hayaksi1

Copy link
Copy Markdown
Contributor Author

Done!

Codecov flagged the patch at 50%: accepting the intent as soon as it carries uris short-circuits the mime type list, so type.isMimeTypeImage() was only ever evaluated to false. The new tests run one intent per listed mime type with no uri, which takes that line — and the whole when — to full branch coverage.

While the handler was under test I covered the paths that had none: an intent with no resolvable type, an ACTION_SEND_MULTIPLE with no stream, an action which is neither send nor send multiple, an empty caption, a plain text intent with no text, the mime type the content resolver reports for the uri, and the explicit intent built for the application which will read it, both when the read permission can be granted and when it cannot.

DefaultShareIntentHandler.kt is now at 45/45 lines and 49/50 branches with :features:share:impl:koverXmlReport. The remaining branch is the null check Kotlin generates for ?.toString() on line 54, which cannot be taken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Z-Community-PR Issue is solved by a community member's PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VC 202510010 fails to consume an intent:#Intent;action=android.intent.action.SEND;type=message/rfc822 containing a file *and* text/plain.

2 participants