Commit 81074f86 authored by Jan Henning's avatar Jan Henning Committed by Georg Koppen
Browse files

Bug 1500906 - Suppress FileUriExposedExceptions when launching helper apps. r=jchen, a=pascalc

Sharing tabs with file:// URIs is not possible, but users can still send them to
other apps via the helper app system in the URL bar/context menu. "Intent:Open"
and "Intent:OpenForResult" are both sent from Gecko by HelperApps.jsm.

The same reasoning as in bug 1450449 applies as to why for publicly accessible
files content:// URIs are more trouble than they're worth.

Differential Revision: https://phabricator.services.mozilla.com/D9697
parent 28a2828d
Loading
Loading
Loading
Loading
+17 −6
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Environment;
import android.os.StrictMode;
import android.provider.Browser;
import android.provider.MediaStore;
import android.support.annotation.Nullable;
@@ -471,12 +472,18 @@ public final class IntentHelper implements BundleEventListener {
    }

    private void open(final GeckoBundle message) {
        final StrictMode.VmPolicy prevPolicy = StrictMode.getVmPolicy();
        StrictMode.setVmPolicy(StrictMode.VmPolicy.LAX);
        try {
            openUriExternal(message.getString("url", ""),
                            message.getString("mime", ""),
                            message.getString("packageName", ""),
                            message.getString("className", ""),
                            message.getString("action", ""),
                            message.getString("title", ""), false);
        } finally {
            StrictMode.setVmPolicy(prevPolicy);
        }
    }

    private void openForResult(final GeckoBundle message, final EventCallback callback) {
@@ -495,10 +502,14 @@ public final class IntentHelper implements BundleEventListener {
            return;
        }
        final ResultHandler handler = new ResultHandler(callback);
        final StrictMode.VmPolicy prevPolicy = StrictMode.getVmPolicy();
        StrictMode.setVmPolicy(StrictMode.VmPolicy.LAX);
        try {
            ActivityHandlerHelper.startIntentForActivity(activity, intent, handler);
        } catch (SecurityException e) {
            Log.w(LOGTAG, "Forbidden to launch activity.", e);
        } finally {
            StrictMode.setVmPolicy(prevPolicy);
        }
    }