From 53734255ec270b0814946350787393dfcaa2a5a9 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 16 Feb 2024 11:49:30 +0100 Subject: [PATCH] Add a check on incoming intent. --- changelog.d/+check-intent.bugfix | 1 + .../im/vector/app/features/MainActivity.kt | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 changelog.d/+check-intent.bugfix diff --git a/changelog.d/+check-intent.bugfix b/changelog.d/+check-intent.bugfix new file mode 100644 index 0000000000..728ae13275 --- /dev/null +++ b/changelog.d/+check-intent.bugfix @@ -0,0 +1 @@ +Add a check on incoming intent. diff --git a/vector/src/main/java/im/vector/app/features/MainActivity.kt b/vector/src/main/java/im/vector/app/features/MainActivity.kt index c8aa108ccb..0f0ac83903 100644 --- a/vector/src/main/java/im/vector/app/features/MainActivity.kt +++ b/vector/src/main/java/im/vector/app/features/MainActivity.kt @@ -39,6 +39,9 @@ import im.vector.app.features.analytics.VectorAnalytics import im.vector.app.features.analytics.plan.ViewRoom import im.vector.app.features.home.HomeActivity import im.vector.app.features.home.ShortcutsHandler +import im.vector.app.features.home.room.detail.RoomDetailActivity +import im.vector.app.features.home.room.threads.ThreadsActivity +import im.vector.app.features.location.live.map.LiveLocationMapViewActivity import im.vector.app.features.notifications.NotificationDrawerManager import im.vector.app.features.pin.UnlockedActivity import im.vector.app.features.pin.lockscreen.crypto.LockScreenKeyRepository @@ -115,6 +118,14 @@ class MainActivity : VectorBaseActivity(), UnlockedActivity putExtra(EXTRA_ROOM_ID, roomId) } } + + val allowList = listOf( + HomeActivity::class.java.name, + MainActivity::class.java.name, + RoomDetailActivity::class.java.name, + ThreadsActivity::class.java.name, + LiveLocationMapViewActivity::class.java.name, + ) } private val startAppViewModel: StartAppViewModel by viewModel() @@ -186,6 +197,7 @@ class MainActivity : VectorBaseActivity(), UnlockedActivity // Start the next Activity startSyncing() val nextIntent = intent.getParcelableExtraCompat(EXTRA_NEXT_INTENT) + ?.takeIf { it.isValid() } startIntentAndFinish(nextIntent) } else if (intent.hasExtra(EXTRA_INIT_SESSION)) { startSyncing() @@ -380,4 +392,11 @@ class MainActivity : VectorBaseActivity(), UnlockedActivity intent?.let { startActivity(it) } finish() } + + private fun Intent.isValid(): Boolean { + val componentName = resolveActivity(packageManager) ?: return false + val packageName = componentName.packageName + val className = componentName.className + return packageName == buildMeta.applicationId && className in allowList + } }