Bug 1193027 - Disables all downloads of file:// urls on Android. r=snorp
authorDylan Roeh <droeh@mozilla.com>
Tue, 08 Sep 2015 15:41:36 -0500
changeset 294718 0c24126a81e5925d60e73b0dfcc76b2691e0cab9
parent 294717 c2d62280bd5ca124b91d4e2d1350d840f0025274
child 294719 609b337bf7abb7f6f4750108e329684ca975d6ed
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1193027
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1193027 - Disables all downloads of file:// urls on Android. r=snorp
mobile/android/components/HelperAppDialog.js
--- a/mobile/android/components/HelperAppDialog.js
+++ b/mobile/android/components/HelperAppDialog.js
@@ -58,17 +58,18 @@ HelperAppLauncherDialog.prototype = {
         url.schemeIs("ftp")) {
       return true;
     }
 
     // The less-common opposite case.
     if (url.schemeIs("chrome") ||
         url.schemeIs("jar") ||
         url.schemeIs("resource") ||
-        url.schemeIs("wyciwyg")) {
+        url.schemeIs("wyciwyg") ||
+        url.schemeIs("file")) {
       return false;
     }
 
     // For all other URIs, try to resolve them to an inner URI, and check that.
     if (!alreadyResolved) {
       let ioSvc = Cc["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
       let innerURI = ioSvc.newChannelFromURI2(url,
                                               null,      // aLoadingNode
@@ -76,41 +77,16 @@ HelperAppLauncherDialog.prototype = {
                                               null,      // aTriggeringPrincipal
                                               Ci.nsILoadInfo.SEC_NORMAL,
                                               Ci.nsIContentPolicy.TYPE_OTHER).URI;
       if (!url.equals(innerURI)) {
         return this._canDownload(innerURI, true);
       }
     }
 
-    if (url.schemeIs("file")) {
-      // If it's in our app directory or profile directory, we never ever
-      // want to do anything with it, including saving to disk or passing the
-      // file to another application.
-      let file = url.QueryInterface(Ci.nsIFileURL).file;
-
-      // Normalize the nsILocalFile in-place. This will ensure that paths
-      // can be correctly compared via `contains`, below.
-      file.normalize();
-
-      // TODO: pref blacklist?
-
-      let appRoot = FileUtils.getFile("XREExeF", []);
-      if (appRoot.contains(file, true)) {
-        return false;
-      }
-
-      let profileRoot = FileUtils.getFile("ProfD", []);
-      if (profileRoot.contains(file, true)) {
-        return false;
-      }
-
-      return true;
-    }
-
     // Anything else is fine to download.
     return true;
   },
 
   /**
    * Returns true if `launcher` represents a download for which we wish
    * to prompt.
    */