π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Harden Android review intent handling
laurenspriemf5e145d7bf13
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 68de1c5a17..1fa62ae95d 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@@ -32,8 +32,11 @@ class MediaReviewActivity : Activity() {if (reviewIntent.action !in reviewActions) {return Intent(reviewIntent)}- val uri = reviewIntent.data ?: reviewIntent.streamUri ?: return null- val type = reviewIntent.type ?: resolveMimeType(uri) ?: return null+ val uri = reviewIntent.reviewUri ?: return null+ val type = reviewIntent.type+ ?: resolveMimeType(uri)+ ?: reviewIntent.clipDataMimeType+ ?: return nullif (!type.isSupportedReviewMimeType()) {return null}@@ -77,6 +80,33 @@ class MediaReviewActivity : Activity() {@Suppress("DEPRECATION")get() = getParcelableExtra(Intent.EXTRA_STREAM)+ private val Intent.reviewUri: Uri?+ get() = data ?: streamUri ?: firstClipDataUri++ private val Intent.firstClipDataUri: Uri?+ get() {+ val clipData = clipData ?: return null+ for (index in 0 until clipData.itemCount) {+ val uri = clipData.getItemAt(index).uri+ if (uri != null) {+ return uri+ }+ }+ return null+ }++ private val Intent.clipDataMimeType: String?+ get() {+ val description = clipData?.description ?: return null+ for (index in 0 until description.mimeTypeCount) {+ val mimeType = description.getMimeType(index)+ if (mimeType.isSupportedReviewMimeType()) {+ return mimeType+ }+ }+ return null+ }+private companion object {private const val ACTION_REVIEW = "android.provider.action.REVIEW"private const val ACTION_CAMERA_REVIEW = "com.android.camera.action.REVIEW"diff --git a/mobile/apps/photos/lib/ui/viewer/actions/file_viewer.dart b/mobile/apps/photos/lib/ui/viewer/actions/file_viewer.dartindex 9dc251d8c5..cec46d588c 100644--- a/mobile/apps/photos/lib/ui/viewer/actions/file_viewer.dart+++ b/mobile/apps/photos/lib/ui/viewer/actions/file_viewer.dart@@ -187,6 +187,12 @@ class FileViewerState extends State<FileViewer> {mediaSegmentIndex < uri.pathSegments.length - 1) {return uri.pathSegments[mediaSegmentIndex + 1];}+ if (uri.pathSegments.isNotEmpty) {+ final id = uri.pathSegments.last;+ if (int.tryParse(id) != null) {+ return id;+ }+ }}if (uri.authority == "com.android.providers.media.documents" &&uri.pathSegments.isNotEmpty) {@@ -418,7 +424,17 @@ class FileViewerState extends State<FileViewer> {);}- return _boundedPhotoView(MemoryImage(base64Decode(data)));+ if (uri != null && uri.scheme.isNotEmpty) {+ _logger.severe("unsupported image uri $data");+ return const Icon(Icons.error);+ }++ try {+ return _boundedPhotoView(MemoryImage(base64Decode(data)));+ } catch (e, s) {+ _logger.severe("failed to decode shared image payload", e, s);+ return const Icon(Icons.error);+ }}Widget _buildVideoViewer() {