Bug 1218284 - Match signed packages' with trust origin without suffix. r=valentin
authorJonathan Hao <jhao@mozilla.com>
Mon, 26 Oct 2015 15:30:38 +0800
changeset 304853 3045e988dd9f47f0742a23b8b6588df8d8597099
parent 304852 21cc3138e88410ab02c1cd5a979a9c49cbd4dc3b
child 304854 fe68b0a471fa4e92a009c2ef0938acbaa285f245
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1218284
milestone44.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 1218284 - Match signed packages' with trust origin without suffix. r=valentin
netwerk/protocol/http/PackagedAppVerifier.cpp
netwerk/test/unit/test_packaged_app_channel.js
--- a/netwerk/protocol/http/PackagedAppVerifier.cpp
+++ b/netwerk/protocol/http/PackagedAppVerifier.cpp
@@ -13,16 +13,17 @@
 #include "PackagedAppVerifier.h"
 #include "nsITimer.h"
 #include "nsIPackagedAppVerifier.h"
 #include "mozilla/Preferences.h"
 #include "nsIPackagedAppUtils.h"
 #include "nsIInputStream.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIURL.h"
+#include "mozilla/BasePrincipal.h"
 
 static const short kResourceHashType = nsICryptoHash::SHA256;
 
 static bool gSignedAppEnabled = false;
 
 namespace mozilla {
 namespace net {
 
@@ -69,24 +70,25 @@ NS_IMETHODIMP PackagedAppVerifier::Init(
   if (!onceThru) {
     Preferences::AddBoolVarCache(&gSignedAppEnabled,
                                  "network.http.signed-packages.enabled", false);
     onceThru = true;
   }
 
   mListener = aListener;
   mState = STATE_UNKNOWN;
-  mPackageOrigin = aPackageOrigin;
   mSignature = aSignature;
   mIsPackageSigned = false;
   mPackageCacheEntry = aPackageCacheEntry;
   mIsFirstResource = true;
   mManifest = EmptyCString();
 
-  mBypassVerification = (mPackageOrigin ==
+  nsAutoCString originNoSuffix;
+  OriginAttributes().PopulateFromOrigin(aPackageOrigin, originNoSuffix);
+  mBypassVerification = (originNoSuffix ==
       Preferences::GetCString("network.http.signed-packages.trusted-origin"));
 
   nsresult rv;
   mPackagedAppUtils = do_CreateInstance(NS_PACKAGEDAPPUTILS_CONTRACTID, &rv);
   if (NS_FAILED(rv)) {
     LOG(("create packaged app utils failed"));
     return rv;
   }
--- a/netwerk/test/unit/test_packaged_app_channel.js
+++ b/netwerk/test/unit/test_packaged_app_channel.js
@@ -236,17 +236,17 @@ function test_channel_with_bad_signature
     run_next_test();
   }), null);
 }
 
 function test_channel_with_bad_signature_from_trusted_origin() {
   let pref = "network.http.signed-packages.trusted-origin";
   ok(!!Ci.nsISupportsString, "Ci.nsISupportsString");
   let origin = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
-  origin.data = uri + "^appId=1024";
+  origin.data = uri;
   Services.prefs.setComplexValue(pref, Ci.nsISupportsString, origin);
   var channel = make_channel(uri+"/package_with_bad_signature!//index.html");
   channel.notificationCallbacks = new LoadContextCallback(1024, false, false, false);
   channel.asyncOpen(new Listener(function(l) {
     do_check_true(l.gotStopRequestOK);
     Services.prefs.clearUserPref(pref);
     run_next_test();
   }), null);