[fenix] Don't crash when receiving a bad uri via send tab (https://github.com/mozilla-mobile/fenix/pull/24326)

* don't crash when receiving a bad uri via send tab

* changed searchfox link to permalink

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
pull/600/head
Sammy Khamis 3 years ago committed by GitHub
parent f8f1d55760
commit 1da1898262

@ -54,7 +54,11 @@ class NotificationManager(private val context: Context) {
// In the future, experiment with displaying multiple tabs from the same device as as Notification Groups.
// For now, a single notification per tab received will suffice.
logger.debug("Showing ${tabs.size} tab(s) received from deviceID=${device?.id}")
tabs.forEach { tab ->
// We should not be displaying tabs with certain invalid schemes
val filteredTabs = tabs.filter { isValidTabSchema(it) }
logger.debug("${filteredTabs.size} tab(s) after filtering for unsupported schemes")
filteredTabs.forEach { tab ->
val showReceivedTabsIntentFlags = IntentUtils.defaultIntentPendingFlags or PendingIntent.FLAG_ONE_SHOT
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(tab.url))
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
@ -129,3 +133,10 @@ class NotificationManager(private val context: Context) {
return this
}
}
internal fun isValidTabSchema(tab: TabData): Boolean {
// We don't sync certain schemas, about|resource|chrome|file|blob|moz-extension
// See https://searchfox.org/mozilla-central/rev/7d379061bd56251df911728686c378c5820513d8/modules/libpref/init/all.js#4356
val filteredSchemas = arrayOf("about:", "resource:", "chrome:", "file:", "blob:", "moz-extension:")
return filteredSchemas.none({ tab.url.startsWith(it) })
}

Loading…
Cancel
Save