Bug 1193027 - Disables all downloads of file:// urls on Android. r=snorp, a=sylvestre
authorDylan Roeh <droeh@mozilla.com>
Tue, 08 Sep 2015 15:41:36 -0500
changeset 289279 21486457a5bd33fd833d4a4843d4db8623cb60a0
parent 289278 7484c6088282abb5aec8e99fcd0710c46f81b8cb
child 289280 6dce309288326a6b21f6723d47e11edbbcb0d8f2
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp, sylvestre
bugs1193027
milestone42.0a2
Bug 1193027 - Disables all downloads of file:// urls on Android. r=snorp, a=sylvestre
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.
    */