fix: Prevent crash when mimeType is empty and fallback to file extension#658
Open
aymericmariaux wants to merge 14 commits into
Open
fix: Prevent crash when mimeType is empty and fallback to file extension#658aymericmariaux wants to merge 14 commits into
aymericmariaux wants to merge 14 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prevents crashes when mimeType is blank by avoiding unsafe MIME parsing and falling back to filename-based type detection where appropriate.
Changes:
- Ignores blank MIME types in
FileUi.fileType. - Safely derives thumbnail type information in
previewUriForFile. - Falls back to the file name when MIME type is absent or malformed.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
app/src/main/java/com/infomaniak/swisstransfer/ui/utils/FileUiExt.kt |
Uses filename-based file type detection when MIME type is blank. |
app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/TransferManagerExt.kt |
Avoids unsafe substring calls and skips thumbnail generation when URI or extension is unusable. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
949b8b2 to
75cd8d5
Compare
bfc591d to
7a438d8
Compare
FabianDevel
requested changes
Jun 1, 2026
7a438d8 to
04286a7
Compare
tevincent
requested changes
Jun 3, 2026
- Fix crash occurring when `mimeType` was empty or blank: `indexOfLast('/')` returned `-1`, which caused `substring(-1)` to throw `StringIndexOutOfBoundsException`
- Ignore blank `mimeType` so `FileType.guessFromFileName()` and thumbnail generation can fallback to the file's extension when no valid mimeType is provided
14ff010 to
9702c15
Compare
tevincent
requested changes
Jun 5, 2026
1c83279 to
32abfaf
Compare
|
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.



mimeTypewas empty or blank:indexOfLast('/')returned-1, which causedsubstring(-1)to throwStringIndexOutOfBoundsExceptionmimeTypesoFileType.guessFromFileName()and thumbnail generation can fallback to the file's extension when no valid mimeType is provided