Bug 776797 - Lock down POfflineCacheUpdate, r=jduell

This commit is contained in:
Honza Bambas 2012-09-27 21:35:07 +02:00
parent 94e7239133
commit f5af1bf338
2 changed files with 17 additions and 5 deletions

View File

@ -55,6 +55,7 @@ namespace docshell {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
NS_INTERFACE_MAP_BEGIN(OfflineCacheUpdateChild) NS_INTERFACE_MAP_BEGIN(OfflineCacheUpdateChild)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_ENTRY(nsIOfflineCacheUpdate) NS_INTERFACE_MAP_ENTRY(nsIOfflineCacheUpdate)
NS_INTERFACE_MAP_END NS_INTERFACE_MAP_END

View File

@ -8,6 +8,7 @@
#include "mozilla/ipc/URIUtils.h" #include "mozilla/ipc/URIUtils.h"
#include "nsOfflineCacheUpdate.h" #include "nsOfflineCacheUpdate.h"
#include "nsIApplicationCache.h" #include "nsIApplicationCache.h"
#include "nsNetUtil.h"
using namespace mozilla::ipc; using namespace mozilla::ipc;
@ -83,20 +84,30 @@ OfflineCacheUpdateParent::Schedule(const URIParams& aManifestURI,
if (!manifestURI) if (!manifestURI)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
nsCOMPtr<nsIURI> documentURI = DeserializeURI(aDocumentURI);
if (!documentURI)
return NS_ERROR_FAILURE;
nsOfflineCacheUpdateService* service = nsOfflineCacheUpdateService* service =
nsOfflineCacheUpdateService::EnsureService(); nsOfflineCacheUpdateService::EnsureService();
if (!service) if (!service)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
bool offlinePermissionAllowed = false;
nsresult rv = service->OfflineAppAllowedForURI(
manifestURI, nullptr, &offlinePermissionAllowed);
NS_ENSURE_SUCCESS(rv, rv);
if (!offlinePermissionAllowed)
return NS_ERROR_DOM_SECURITY_ERR;
nsCOMPtr<nsIURI> documentURI = DeserializeURI(aDocumentURI);
if (!documentURI)
return NS_ERROR_FAILURE;
if (!NS_SecurityCompareURIs(manifestURI, documentURI, false))
return NS_ERROR_DOM_SECURITY_ERR;
service->FindUpdate(manifestURI, this, getter_AddRefs(update)); service->FindUpdate(manifestURI, this, getter_AddRefs(update));
if (!update) { if (!update) {
update = new nsOfflineCacheUpdate(); update = new nsOfflineCacheUpdate();
nsresult rv;
// Leave aDocument argument null. Only glues and children keep // Leave aDocument argument null. Only glues and children keep
// document instances. // document instances.
rv = update->Init(manifestURI, documentURI, nullptr, nullptr, this); rv = update->Init(manifestURI, documentURI, nullptr, nullptr, this);