Bug 1094257 - nsPrincipal::GetBaseDomain() should not use TLD if the protocol handler of the URI scheme has NORELATIVE flag, r=bz

This commit is contained in:
Andrea Marchesini
2014-11-11 09:10:56 +00:00
parent 0883117bc2
commit d5c6079ff6

View File

@@ -17,6 +17,7 @@
#include "nsIObjectInputStream.h"
#include "nsIObjectOutputStream.h"
#include "nsIClassInfoImpl.h"
#include "nsIProtocolHandler.h"
#include "nsError.h"
#include "nsIContentSecurityPolicy.h"
#include "jswrapper.h"
@@ -490,6 +491,18 @@ nsPrincipal::GetBaseDomain(nsACString& aBaseDomain)
}
}
bool hasNoRelativeFlag;
nsresult rv = NS_URIChainHasFlags(mCodebase,
nsIProtocolHandler::URI_NORELATIVE,
&hasNoRelativeFlag);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
if (hasNoRelativeFlag) {
return mCodebase->GetSpec(aBaseDomain);
}
// For everything else, we ask the TLD service via
// the ThirdPartyUtil.
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil =