fix: preserve accept MIME types in WebView file chooser - #62
Open
OS-pedrogustavobilro wants to merge 4 commits into
Open
fix: preserve accept MIME types in WebView file chooser#62OS-pedrogustavobilro wants to merge 4 commits into
OS-pedrogustavobilro wants to merge 4 commits into
Conversation
Selecting only documents was allow zip files too, because they were falling under an incorrectly assumed application/* wildcard
OS-pedrogustavobilro
marked this pull request as ready for review
August 31, 2026 17:56
OS-pedrogustavobilro
requested review from
ItsChaceD,
andredestro,
jcesarmobile and
theproducer
August 31, 2026 17:57
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.
Description
Fixes the Android
OpenInWebViewfile chooser incorrectly restricting mixed file uploads to images only, plus two related bugs found during manual verification.Root cause:
OSIABWebChromeClient.launchFullChooserpicked a single MIMEtypefor theACTION_GET_CONTENTintent via a naiveacceptTypes.contains("image")/.contains("video")check on a comma-joined accept string. For an HTML input likeaccept="image/*,application/pdf,application/msword", this collapsed the picker down toimage/*, silently dropping PDF/Word/Excel — even though Android natively supports disjoint multi-MIME selection viatype = "*/*"+Intent.EXTRA_MIME_TYPES.Changes:
OSIABFileChooserHelper(helpers/) to resolve rawaccepttokens (MIME types and/or file extensions, e.g..pdf,.docx) into concrete MIME types, and to decide the correcttype/EXTRA_MIME_TYPESpair for the chooser intent.OSIABWebViewActivitynow keeps the accept list structured (List<String>) instead of collapsing it to a joined string, andlaunchFullChooser/buildPhotoVideoIntentsuse the resolved MIME types instead of substring matching.typewith no filtering beyond it. Any time there's more than one distinct resolved MIME type — even when they share a top-level category (e.g.application/pdf+application/msword) — the chooser now always uses*/*+EXTRA_MIME_TYPESwith the exact list, rather than collapsing same-category subtypes into that category's wildcard (e.g.application/*). That collapse was itself a bug:application/*is broad enough to also match zip, octet-stream, JSON, etc., which is not what a documents-onlyacceptlist requested."*/*"is now treated the same as noacceptrestriction at all for capture-shortcut purposes, soaccept="*/*"combined with<input capture>correctly offers photo/video capture instead of silently falling back to (or failing to offer) a chooser.<input capture>with a documents-onlyacceptlist produced an empty capture-intent list, andlaunchCameraChooserindexed into it unconditionally (IndexOutOfBoundsException), which was silently swallowed and canceled the chooser with no visible feedback to the user. It now falls back to the full chooser when nothing is capturable.2.0.3with aCHANGELOG.mdentry.Context
Internal JIRA References:
Type of changes
Tests
Manual testing
A webpage was created that reproduces the issue; to reproduce the bug / the fix:
Mobile apps:
Unit tests
Added
OSIABFileChooserHelperTestcovering:resolveChooserMimeConfig: empty list, single MIME type, same-category collapse (e.g.image/png+image/jpeg→image/*), disjoint categories (*/*+EXTRA_MIME_TYPES), and dedup on anon-distinct input list.
Full existing test suite (
./gradlew testDebugUnitTest) and./gradlew assembleDebugboth pass with no regressions.