Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 46b9d3cf authored by Christopher Tate's avatar Christopher Tate Committed by Android Git Automerger
Browse files

am 425bd876: am d1741ef9: am 1af5fe23: Merge "Require that verified intent...

am 425bd876: am d1741ef9: am 1af5fe23: Merge "Require that verified intent filters only have http/https <data> decls" into mnc-dev

* commit '425bd876':
  Require that verified intent filters only have http/https <data> decls
parents 1f61f07c 425bd876
Loading
Loading
Loading
Loading
+26 −9
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package android.content;

import android.content.pm.PackageParser;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
@@ -534,13 +533,15 @@ public class IntentFilter implements Parcelable {
     */
    public final boolean handleAllWebDataURI() {
        return hasCategory(Intent.CATEGORY_APP_BROWSER) ||
                (hasWebDataURI() && countDataAuthorities() == 0);
                (hasOnlyWebDataURI() && countDataAuthorities() == 0);
    }

    /**
     * Return if this filter has any HTTP or HTTPS data URI or not.
     * Return if this filter handles only HTTP or HTTPS data URIs.
     *
     * @return True if the filter has any HTTP or HTTPS data URI. False otherwise.
     * @return True if the filter handles ACTION_VIEW/CATEGORY_BROWSABLE,
     * has at least one HTTP or HTTPS data URI pattern defined, and does not
     * define any non-http/https data URI patterns.
     *
     * This will check if if the Intent action is {@link android.content.Intent#ACTION_VIEW} and
     * the Intent category is {@link android.content.Intent#CATEGORY_BROWSABLE} and the Intent
@@ -548,10 +549,26 @@ public class IntentFilter implements Parcelable {
     *
     * @hide
     */
    public final boolean hasWebDataURI() {
        return hasAction(Intent.ACTION_VIEW) &&
                hasCategory(Intent.CATEGORY_BROWSABLE) &&
                (hasDataScheme(SCHEME_HTTP) || hasDataScheme(SCHEME_HTTPS));
    public final boolean hasOnlyWebDataURI() {
        // Require ACTION_VIEW, CATEGORY_BROWSEABLE, and at least one scheme
        if (!hasAction(Intent.ACTION_VIEW)
            || !hasCategory(Intent.CATEGORY_BROWSABLE)
            || mDataSchemes == null
            || mDataSchemes.size() == 0) {
            return false;
        }

        // Now allow only the schemes "http" and "https"
        final int N = mDataSchemes.size();
        for (int i = 0; i < N; i++) {
            final String scheme = mDataSchemes.get(i);
            if (!SCHEME_HTTP.equals(scheme) && !SCHEME_HTTPS.equals(scheme)) {
                return false;
            }
        }

        // Everything passed, so it's an only-web-URIs filter
        return true;
    }

    /**
@@ -568,7 +585,7 @@ public class IntentFilter implements Parcelable {
     * @hide
     */
    public final boolean needsVerification() {
        return hasWebDataURI() && getAutoVerify();
        return getAutoVerify() && hasOnlyWebDataURI();
    }

    /**
+1 −2
Original line number Diff line number Diff line
@@ -12018,8 +12018,7 @@ public class PackageManagerService extends IPackageManager.Stub {
                final int verificationId = mIntentFilterVerificationToken++;
                for (PackageParser.Activity a : pkg.activities) {
                    for (ActivityIntentInfo filter : a.intents) {
                        boolean needsFilterVerification = filter.hasWebDataURI();
                        if (needsFilterVerification && needsNetworkVerificationLPr(filter)) {
                        if (filter.hasOnlyWebDataURI() && needsNetworkVerificationLPr(filter)) {
                            if (DEBUG_DOMAIN_VERIFICATION) Slog.d(TAG,
                                    "Verification needed for IntentFilter:" + filter.toString());
                            mIntentFilterVerifier.addOneIntentFilterVerification(