From 134109454587fa922937d5d9ec9c807977126968 Mon Sep 17 00:00:00 2001 From: Florian Renaud Date: Fri, 29 Oct 2021 17:11:07 +0200 Subject: [PATCH 1/2] Fix permalink handling whole link base url was compared to supported hosts instead of the host part only --- .../main/java/im/vector/app/features/home/HomeActivity.kt | 3 +-- .../im/vector/app/features/permalink/PermalinkHandler.kt | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt b/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt index e8af044bbd3..1ad08ac8e99 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt @@ -273,14 +273,13 @@ class HomeActivity : val resolvedLink = when { // Element custom scheme is not handled by the sdk, convert it to matrix.to link for compatibility deepLink.startsWith(MATRIX_TO_CUSTOM_SCHEME_URL_BASE) -> { - val let = when { + when { deepLink.startsWith(USER_LINK_PREFIX) -> deepLink.substring(USER_LINK_PREFIX.length) deepLink.startsWith(ROOM_LINK_PREFIX) -> deepLink.substring(ROOM_LINK_PREFIX.length) else -> null }?.let { permalinkId -> activeSessionHolder.getSafeActiveSession()?.permalinkService()?.createPermalink(permalinkId) } - let } else -> deepLink } diff --git a/vector/src/main/java/im/vector/app/features/permalink/PermalinkHandler.kt b/vector/src/main/java/im/vector/app/features/permalink/PermalinkHandler.kt index d4eed6a41e6..40cc0b3e139 100644 --- a/vector/src/main/java/im/vector/app/features/permalink/PermalinkHandler.kt +++ b/vector/src/main/java/im/vector/app/features/permalink/PermalinkHandler.kt @@ -18,6 +18,7 @@ package im.vector.app.features.permalink import android.content.Context import android.net.Uri +import androidx.core.net.toUri import im.vector.app.R import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.extensions.isIgnored @@ -118,9 +119,8 @@ class PermalinkHandler @Inject constructor(private val activeSessionHolder: Acti private fun isPermalinkSupported(context: Context, url: String): Boolean { return url.startsWith(PermalinkService.MATRIX_TO_URL_BASE) || - context.resources.getStringArray(R.array.permalink_supported_hosts).any { - url.startsWith(it) - } + context.resources.getStringArray(R.array.permalink_supported_hosts) + .any { url.toUri().host == it } } private suspend fun PermalinkData.RoomLink.getRoomId(): String? { From 13dc0e0c110403b76e9c438e1340bd2a02ee69a5 Mon Sep 17 00:00:00 2001 From: Florian Renaud Date: Fri, 29 Oct 2021 18:49:18 +0200 Subject: [PATCH 2/2] Add towncrier --- changelog.d/4369.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/4369.bugfix diff --git a/changelog.d/4369.bugfix b/changelog.d/4369.bugfix new file mode 100644 index 00000000000..43ce71cbb8e --- /dev/null +++ b/changelog.d/4369.bugfix @@ -0,0 +1 @@ +Fix handling of links coming from web instance reported as malformed by mistake \ No newline at end of file