From aab67c2b9d1643d6ee97f1a49e714cfb2a49e73b Mon Sep 17 00:00:00 2001 From: Patrick Baumann Date: Thu, 9 Jul 2020 11:36:15 -0700 Subject: [PATCH] Don't assume host is wildcard if not provided This change ensures that while parsing a package, we require an explicit wildcard in the queries->intent->data->host field. Prior to this change, we were defaulting to wildcard when not provided. This resulted in, e.g. someone trying to get visibility to just browsers actually getting access to all packages that handle any web intent. Fixes: 160868841 Test: atest AppEnumerationTests IntentFilterTest Change-Id: I771845467928b6655fe19efe89bd2ca548dca6e5 --- core/java/android/content/IntentFilter.java | 7 ++++++- .../android/content/pm/parsing/ParsingPackageUtils.java | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/java/android/content/IntentFilter.java b/core/java/android/content/IntentFilter.java index 79da1f6ab2826..ee9bd3d259fb8 100644 --- a/core/java/android/content/IntentFilter.java +++ b/core/java/android/content/IntentFilter.java @@ -1168,7 +1168,12 @@ public class IntentFilter implements Parcelable { public int match(Uri data, boolean wildcardSupported) { String host = data.getHost(); if (host == null) { - return NO_MATCH_DATA; + if (wildcardSupported && mWild) { + // special case, if no host is provided, but the Authority is wildcard, match + return MATCH_CATEGORY_HOST; + } else { + return NO_MATCH_DATA; + } } if (false) Log.v("IntentFilter", "Match host " + host + ": " + mHost); diff --git a/core/java/android/content/pm/parsing/ParsingPackageUtils.java b/core/java/android/content/pm/parsing/ParsingPackageUtils.java index bc9c71e7a68e9..ab0ed51fb909f 100644 --- a/core/java/android/content/pm/parsing/ParsingPackageUtils.java +++ b/core/java/android/content/pm/parsing/ParsingPackageUtils.java @@ -1510,7 +1510,7 @@ public class ParsingPackageUtils { Uri data = null; String dataType = null; - String host = IntentFilter.WILDCARD; + String host = null; final int numActions = intentInfo.countActions(); final int numSchemes = intentInfo.countDataSchemes(); final int numTypes = intentInfo.countDataTypes();