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

Bug 17334: Spoof referrer when leaving a .onion domain

Note I also remove a superfluous and confusing line,
`currentHost = referrerHost;`
parent 5be9836b
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
#include "nsMimeTypes.h"
#include "nsNetCID.h"
#include "nsNetUtil.h"
#include "nsReadableUtils.h"

#include "nsICachingChannel.h"
#include "nsIDOMDocument.h"
@@ -1391,13 +1392,15 @@ HttpBaseChannel::SetReferrerWithPolicy(nsIURI *referrer,
      return NS_OK;
  }

  // send spoofed referrer if desired
  if (userSpoofReferrerSource) {
  bool leavingOnion = !currentHost.Equals(referrerHost) &&
    StringEndsWith(referrerHost, NS_LITERAL_CSTRING(".onion"));

  // send spoofed referrer if desired by user, or if we are leaving a .onion
  if (userSpoofReferrerSource || leavingOnion) {
    nsCOMPtr<nsIURI> mURIclone;
    rv = mURI->CloneIgnoringRef(getter_AddRefs(mURIclone));
    if (NS_FAILED(rv)) return rv;
    clone = mURIclone;
    currentHost = referrerHost;
  }

  // strip away any userpass; we don't want to be giving out passwords ;-)