Commit b3358c0e authored by MozLando's avatar MozLando
Browse files

Merge #6767 #6794 #6795

6767: Close #6674: Don't crash in AppLinksUsesCases with illegal Intent URI format r=csadilek a=rocketsroger



6794:  GeckoView update (nightly) (20200428-140644) r=psymoon a=MickeyMoz



6795: Issue #6331: Update the generated top sites schemas r=Amejia481 a=gabrielluong

This is a follow up to https://github.com/mozilla-mobile/android-components/pull/6715

, where the top sites schema did not regenerate after fixing the review comments.
Co-authored-by: default avatarRoger Yang <royang@mozilla.com>
Co-authored-by: default avatarMickeyMoz <sebastian@mozilla.com>
Co-authored-by: default avatarGabriel Luong <gabriel.luong@gmail.com>
......@@ -6,7 +6,7 @@ internal object GeckoVersions {
/**
* GeckoView Nightly Version.
*/
const val nightly_version = "77.0.20200427094322"
const val nightly_version = "77.0.20200428100141"
/**
* GeckoView Beta Version.
......
......@@ -13,6 +13,7 @@ import android.net.Uri
import androidx.annotation.VisibleForTesting
import mozilla.components.support.base.log.logger.Logger
import mozilla.components.support.ktx.android.net.isHttpOrHttps
import java.net.URISyntaxException
import java.util.UUID
private const val EXTRA_BROWSER_FALLBACK_URL = "browser_fallback_url"
......@@ -63,11 +64,20 @@ class AppLinksUseCases(
return context.packageManager.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY)
}
private fun safeParseUri(uri: String, flags: Int): Intent? {
return try {
Intent.parseUri(uri, flags)
} catch (e: URISyntaxException) {
null
}
}
private fun findExcludedPackages(randomWebURLString: String): Set<String> {
val intent = safeParseUri(randomWebURLString, 0) ?: return emptySet()
// We generate a URL is not likely to be opened by a native app
// but will fallback to a browser.
// In this way, we're looking for only the browsers — including us.
return findActivities(Intent.parseUri(randomWebURLString, 0).addCategory(Intent.CATEGORY_BROWSABLE))
return findActivities(intent.addCategory(Intent.CATEGORY_BROWSABLE))
.map { it.activityInfo.packageName }
.toHashSet()
}
......@@ -136,19 +146,19 @@ class AppLinksUseCases(
}
private fun createBrowsableIntents(url: String): RedirectData {
val intent = Intent.parseUri(url, 0)
if (intent.action == Intent.ACTION_VIEW) {
val intent = safeParseUri(url, 0)
if (intent != null && intent.action == Intent.ACTION_VIEW) {
intent.addCategory(Intent.CATEGORY_BROWSABLE)
intent.component = null
intent.selector = null
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
}
val fallbackIntent = intent.getStringExtra(EXTRA_BROWSER_FALLBACK_URL)?.let {
val fallbackIntent = intent?.getStringExtra(EXTRA_BROWSER_FALLBACK_URL)?.let {
Intent.parseUri(it, 0)
}
val marketplaceIntent = intent.`package`?.let {
val marketplaceIntent = intent?.`package`?.let {
if (includeInstallAppFallback) {
Intent.parseUri(MARKET_INTENT_URI_PACKAGE_PREFIX + it, 0)
} else {
......@@ -173,8 +183,8 @@ class AppLinksUseCases(
}
val appIntent = when {
intent.data == null -> null
alwaysDeniedSchemes.contains(intent?.data?.scheme) -> null
intent?.data == null -> null
alwaysDeniedSchemes.contains(intent.data?.scheme) -> null
else -> intent
}
......
......@@ -81,6 +81,14 @@ class AppLinksUseCasesTest {
return context
}
@Test
fun `A malformed URL should not cause a crash`() {
val context = createContext()
val subject = AppLinksUseCases(context, { true }, browserPackageNames = emptySet())
val redirect = subject.interceptedAppLinkRedirect("test://test#Intent;")
assertFalse(redirect.isRedirect())
}
@Test
fun `A URL that matches zero apps is not an app link`() {
val context = createContext()
......@@ -169,7 +177,7 @@ class AppLinksUseCasesTest {
}
@Test
fun `browser package names is lazily intialized`() {
fun `browser package names is lazily initialized`() {
val unguessable = "https://unguessable-test-url.com"
val context = createContext(unguessable to browserPackage)
val subject = AppLinksUseCases(context, unguessableWebUrl = unguessable)
......
......@@ -2,11 +2,11 @@
"formatVersion": 1,
"database": {
"version": 2,
"identityHash": "a57788de8a7351e0bdaf5a2044489dcf",
"identityHash": "4c6cae8272b2580de8cb444de31f27d5",
"entities": [
{
"tableName": "top_sites",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `title` TEXT NOT NULL, `url` TEXT NOT NULL, `isDefault` INTEGER NOT NULL, `created_at` INTEGER NOT NULL)",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `title` TEXT NOT NULL, `url` TEXT NOT NULL, `is_default` INTEGER NOT NULL, `created_at` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
......@@ -28,7 +28,7 @@
},
{
"fieldPath": "isDefault",
"columnName": "isDefault",
"columnName": "is_default",
"affinity": "INTEGER",
"notNull": true
},
......@@ -52,7 +52,7 @@
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'a57788de8a7351e0bdaf5a2044489dcf')"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '4c6cae8272b2580de8cb444de31f27d5')"
]
}
}
\ No newline at end of file
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment