Bug 1193093 - Tighten up these checks a little. r=Gijs
☠☠ backed out by 3858cae0e822 ☠ ☠
authorBlake Kaplan <mrbkap@gmail.com>
Mon, 22 Feb 2016 14:00:55 -0800
changeset 333202 6f20995bd994c68fc554676ef92868be779eb312
parent 333201 11a7fbfbe2d15485e63338f0b03eb235008004cb
child 333203 a817cee8f9e68100131d585f65260d24d6da1da4
push id11295
push userbmo:rail@mozilla.com
push dateMon, 22 Feb 2016 23:51:29 +0000
reviewersGijs
bugs1193093
milestone47.0a1
Bug 1193093 - Tighten up these checks a little. r=Gijs
browser/components/feeds/WebContentConverter.js
--- a/browser/components/feeds/WebContentConverter.js
+++ b/browser/components/feeds/WebContentConverter.js
@@ -152,20 +152,21 @@ const Utils = {
     // XXX this should be a "security exception" according to spec, but that
     // isn't defined yet.
     if (uri.scheme != "http" && uri.scheme != "https")
       throw("Permission denied to add " + uri.spec + " as a content or protocol handler");
 
     // We also reject handlers registered from a different host (see bug 402287)
     // The pref allows us to test the feature
     let pb = Services.prefs;
-    if ((!pb.prefHasUserValue(PREF_ALLOW_DIFFERENT_HOST) ||
-         !pb.getBoolPref(PREF_ALLOW_DIFFERENT_HOST)) &&
-        aContentWindow.location.hostname != uri.host)
+    if (!pb.getBoolPref(PREF_ALLOW_DIFFERENT_HOST) &&
+        (!["http", "https"].includes(aContentWindow.location.protocol) ||
+         aContentWindow.location.hostname != uri.host)) {
       throw("Permission denied to add " + uri.spec + " as a content or protocol handler");
+    }
 
     // If the uri doesn't contain '%s', it won't be a good handler
     if (uri.spec.indexOf("%s") < 0)
       throw NS_ERROR_DOM_SYNTAX_ERR;
 
     return uri;
   },