Skip to content

Commit 32904ad

Browse files
Bug 17334: Spoof referrer when leaving a .onion domain
Note I also remove a superfluous and confusing line, `currentHost = referrerHost;`
1 parent b8726ee commit 32904ad

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

netwerk/protocol/http/HttpBaseChannel.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "nsMimeTypes.h"
1515
#include "nsNetCID.h"
1616
#include "nsNetUtil.h"
17+
#include "nsReadableUtils.h"
1718

1819
#include "nsICachingChannel.h"
1920
#include "nsIDOMDocument.h"
@@ -1389,13 +1390,15 @@ HttpBaseChannel::SetReferrerWithPolicy(nsIURI *referrer,
13891390
return NS_OK;
13901391
}
13911392

1392-
// send spoofed referrer if desired
1393-
if (userSpoofReferrerSource) {
1393+
bool leavingOnion = !currentHost.Equals(referrerHost) &&
1394+
StringEndsWith(referrerHost, NS_LITERAL_CSTRING(".onion"));
1395+
1396+
// send spoofed referrer if desired by user, or if we are leaving a .onion
1397+
if (userSpoofReferrerSource || leavingOnion) {
13941398
nsCOMPtr<nsIURI> mURIclone;
13951399
rv = mURI->CloneIgnoringRef(getter_AddRefs(mURIclone));
13961400
if (NS_FAILED(rv)) return rv;
13971401
clone = mURIclone;
1398-
currentHost = referrerHost;
13991402
}
14001403

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

0 commit comments

Comments
 (0)