π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add extra defensive guard for MIME without type
laurenspriem69636222f1a2
diff --git a/mobile/apps/photos/android/app/src/main/kotlin/io/ente/photos/MediaReviewActivity.kt b/mobile/apps/photos/android/app/src/main/kotlin/io/ente/photos/MediaReviewActivity.ktindex 7366a578a0..08e81cb490 100644--- a/mobile/apps/photos/android/app/src/main/kotlin/io/ente/photos/MediaReviewActivity.kt+++ b/mobile/apps/photos/android/app/src/main/kotlin/io/ente/photos/MediaReviewActivity.kt@@ -9,29 +9,37 @@ import java.util.Localeclass MediaReviewActivity : FlutterFragmentActivity() {override fun onCreate(savedInstanceState: Bundle?) {- normalizeReviewIntent(intent)+ val shouldHandleIntent = normalizeReviewIntent(intent)super.onCreate(savedInstanceState)+ if (!shouldHandleIntent) {+ finish()+ }}override fun onNewIntent(intent: Intent) {- normalizeReviewIntent(intent)+ val shouldHandleIntent = normalizeReviewIntent(intent)super.onNewIntent(intent)- setIntent(intent)+ if (shouldHandleIntent) {+ setIntent(intent)+ } else {+ finish()+ }}- private fun normalizeReviewIntent(intent: Intent?) {- val reviewIntent = intent ?: return+ private fun normalizeReviewIntent(intent: Intent?): Boolean {+ val reviewIntent = intent ?: return falseif (reviewIntent.action !in reviewActions) {- return+ return true}- val uri = reviewIntent.data ?: reviewIntent.streamUri- val type = reviewIntent.type ?: uri?.let { resolveMimeType(it) }- reviewIntent.action = Intent.ACTION_VIEW- if (uri != null && type != null) {- reviewIntent.setDataAndType(uri, type)- } else if (uri != null) {- reviewIntent.data = uri+ val uri = reviewIntent.data ?: reviewIntent.streamUri ?: return false+ val type = reviewIntent.type ?: resolveMimeType(uri) ?: return false+ if (!type.isSupportedReviewMimeType()) {+ return false}++ reviewIntent.action = Intent.ACTION_VIEW+ reviewIntent.setDataAndType(uri, type)+ return true}private fun resolveMimeType(uri: Uri): String? {@@ -57,6 +65,12 @@ class MediaReviewActivity : FlutterFragmentActivity() {return MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension)}+ private fun String.isSupportedReviewMimeType(): Boolean {+ val normalizedType = lowercase(Locale.ROOT)+ return normalizedType.startsWith("image/") ||+ normalizedType.startsWith("video/")+ }+private val Intent.streamUri: Uri?@Suppress("DEPRECATION")get() = getParcelableExtra(Intent.EXTRA_STREAM)