Commit e4e326d1 authored by Arthur Edelstein's avatar Arthur Edelstein Committed by Georg Koppen
Browse files

Revert "Bug #15502. Isolate blob URLs to first party; no blobURLs in Web Workers"

This reverts commit 7a8d11b1.
parent d01aaacc
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -250,12 +250,6 @@ ChromeActions.prototype = {
      filename = 'document.pdf';
    }
    var blobUri = data.blobUrl ? NetUtil.newURI(data.blobUrl) : originalUri;
    var netChannel;
    try {
      netChannel = NetUtil.newChannel(blobUri);
    } catch (e) {
      netChannel = NetUtil.newChannel(originalUri);
    }
    var extHelperAppSvc =
          Cc['@mozilla.org/uriloader/external-helper-app-service;1'].
             getService(Ci.nsIExternalHelperAppService);
@@ -263,6 +257,7 @@ ChromeActions.prototype = {
                         getService(Ci.nsIWindowWatcher).activeWindow;

    var docIsPrivate = this.isInPrivateBrowsing();
    var netChannel = NetUtil.newChannel(blobUri);
    if ('nsIPrivateBrowsingChannel' in Ci &&
        netChannel instanceof Ci.nsIPrivateBrowsingChannel) {
      netChannel.setPrivate(docIsPrivate);
+1 −8
Original line number Diff line number Diff line
@@ -1152,14 +1152,7 @@ PDFJS.createObjectURL = (function createObjectURLClosure() {
    if (!PDFJS.disableCreateObjectURL &&
        typeof URL !== 'undefined' && URL.createObjectURL) {
      var blob = PDFJS.createBlob(data, contentType);
      try {
      return URL.createObjectURL(blob);
      } catch(e) {
        // URL.createObjectURL has thrown an error; continue to
        // data schema fallback.
        // TODO: Remove this try-catch when we re-enable
        // createObjectURL in workers.
      }
    }
    var buffer = 'data:' + contentType + ';base64,';
+0 −9
Original line number Diff line number Diff line
@@ -756,12 +756,3 @@ ThirdPartyUtil::GetFirstPartyHostForIsolation(nsIURI *aFirstPartyURI,
  aHost.Append("--");
  return NS_OK;
}

NS_IMETHODIMP
ThirdPartyUtil::GetFirstPartyHostFromCaller(nsACString& aHost) {
  nsCOMPtr<nsIURI> uri;
  nsresult rv = GetFirstPartyIsolationURI(nullptr,
                 nsContentUtils::GetDocumentFromCaller(), getter_AddRefs(uri));
  NS_ENSURE_SUCCESS(rv, rv);
  return GetFirstPartyHostForIsolation(uri, aHost);
}
+2 −21
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@
#include "mozilla/dom/File.h"
#include "mozilla/Preferences.h"
#include "mozilla/LoadInfo.h"
#include "mozIThirdPartyUtil.h"

using mozilla::dom::FileImpl;
using mozilla::ErrorResult;
@@ -30,20 +29,9 @@ struct DataInfo
  nsCOMPtr<nsISupports> mObject;
  nsCOMPtr<nsIPrincipal> mPrincipal;
  nsCString mStack;
  nsCString mFirstPartyHost;
};

static nsClassHashtable<nsCStringHashKey, DataInfo>* gDataTable;
static nsCOMPtr<mozIThirdPartyUtil> gThirdPartyUtilService;

static nsCString GetFirstPartyHostFromCaller() {
  if (!gThirdPartyUtilService) {
    gThirdPartyUtilService = do_GetService(THIRDPARTYUTIL_CONTRACTID);
  }
  nsCString host;
  gThirdPartyUtilService->GetFirstPartyHostFromCaller(host);
  return host;
}

// Memory reporting for the hash table.
namespace mozilla {
@@ -325,8 +313,6 @@ nsHostObjectProtocolHandler::AddDataEntry(const nsACString& aScheme,

  info->mObject = aObject;
  info->mPrincipal = aPrincipal;
  // Record the first party host that originated this object.
  info->mFirstPartyHost = GetFirstPartyHostFromCaller();
  mozilla::BlobURLsReporter::GetJSStackForBlob(info);

  gDataTable->Put(aUri, info);
@@ -451,10 +437,7 @@ GetDataObject(nsIURI* aURI)
  aURI->GetSpec(spec);

  DataInfo* info = GetDataInfo(spec);
  // Deny access to this object if the current first-party host
  // doesn't match the originating first-party host.
  return (info && info->mFirstPartyHost == GetFirstPartyHostFromCaller())
         ? info->mObject : nullptr;
  return info ? info->mObject : nullptr;
}

// -----------------------------------------------------------------------
@@ -512,9 +495,7 @@ nsHostObjectProtocolHandler::NewChannel2(nsIURI* uri,

  DataInfo* info = GetDataInfo(spec);

  // Deny access to this URI if the current first party host
  // doesn't match the first party host when it was created.
  if (!info || (info->mFirstPartyHost != GetFirstPartyHostFromCaller())) {
  if (!info) {
    return NS_ERROR_DOM_BAD_URI;
  }

+0 −7
Original line number Diff line number Diff line
@@ -889,13 +889,6 @@ URL::CreateObjectURL(const GlobalObject& aGlobal, File& aBlob,
  JSContext* cx = aGlobal.Context();
  WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx);

  if (!workerPrivate->IsChromeWorker()) {
    workerPrivate->ReportError(cx, "Worker attempted to use createObjectURL; denied.", nullptr);
    NS_NAMED_LITERAL_STRING(argStr, "URL.createObjectURL");
    aRv.ThrowTypeError(MSG_METHOD_THIS_UNWRAPPING_DENIED, &argStr);
    return;
  }

  nsRefPtr<FileImpl> blobImpl = aBlob.Impl();
  MOZ_ASSERT(blobImpl);

Loading