mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-21 07:47:32 +09:00
Issue #2258 - Part 1: Support XCTO:nosniff when navigating.
This commit is contained in:
parent
723180132d
commit
e56e5d6cb1
10 changed files with 103 additions and 5 deletions
|
|
@ -66,6 +66,7 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
|
|||
, mForcePreflight(false)
|
||||
, mIsPreflight(false)
|
||||
, mLoadTriggeredFromExternal(false)
|
||||
, mSkipContentSniffing(false)
|
||||
, mIsFromProcessingFrameAttributes(false)
|
||||
{
|
||||
MOZ_ASSERT(mLoadingPrincipal);
|
||||
|
|
@ -241,6 +242,7 @@ LoadInfo::LoadInfo(nsPIDOMWindowOuter* aOuterWindow,
|
|||
, mForcePreflight(false)
|
||||
, mIsPreflight(false)
|
||||
, mLoadTriggeredFromExternal(false)
|
||||
, mSkipContentSniffing(false)
|
||||
, mIsFromProcessingFrameAttributes(false)
|
||||
{
|
||||
// Top-level loads are never third-party
|
||||
|
|
@ -305,6 +307,7 @@ LoadInfo::LoadInfo(const LoadInfo& rhs)
|
|||
, mForcePreflight(rhs.mForcePreflight)
|
||||
, mIsPreflight(rhs.mIsPreflight)
|
||||
, mLoadTriggeredFromExternal(rhs.mLoadTriggeredFromExternal)
|
||||
, mSkipContentSniffing(rhs.mSkipContentSniffing)
|
||||
, mIsFromProcessingFrameAttributes(rhs.mIsFromProcessingFrameAttributes)
|
||||
{
|
||||
}
|
||||
|
|
@ -333,7 +336,8 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
|
|||
const nsTArray<nsCString>& aCorsUnsafeHeaders,
|
||||
bool aForcePreflight,
|
||||
bool aIsPreflight,
|
||||
bool aLoadTriggeredFromExternal)
|
||||
bool aLoadTriggeredFromExternal,
|
||||
bool aSkipContentSniffing)
|
||||
: mLoadingPrincipal(aLoadingPrincipal)
|
||||
, mTriggeringPrincipal(aTriggeringPrincipal)
|
||||
, mPrincipalToInherit(aPrincipalToInherit)
|
||||
|
|
@ -357,6 +361,7 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
|
|||
, mForcePreflight(aForcePreflight)
|
||||
, mIsPreflight(aIsPreflight)
|
||||
, mLoadTriggeredFromExternal(aLoadTriggeredFromExternal)
|
||||
, mSkipContentSniffing(aSkipContentSniffing)
|
||||
, mIsFromProcessingFrameAttributes(false)
|
||||
{
|
||||
// Only top level TYPE_DOCUMENT loads can have a null loadingPrincipal
|
||||
|
|
@ -965,6 +970,17 @@ LoadInfo::MaybeIncreaseTainting(uint32_t aTainting)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetSkipContentSniffing(bool* aSkipContentSniffing) {
|
||||
*aSkipContentSniffing = mSkipContentSniffing;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::SetSkipContentSniffing(bool aSkipContentSniffing) {
|
||||
mSkipContentSniffing = aSkipContentSniffing;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetIsTopLevelLoad(bool *aResult)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -111,7 +111,8 @@ private:
|
|||
const nsTArray<nsCString>& aUnsafeHeaders,
|
||||
bool aForcePreflight,
|
||||
bool aIsPreflight,
|
||||
bool aLoadTriggeredFromExternal);
|
||||
bool aLoadTriggeredFromExternal,
|
||||
bool aSkipContentSniffing);
|
||||
LoadInfo(const LoadInfo& rhs);
|
||||
|
||||
friend nsresult
|
||||
|
|
@ -157,6 +158,7 @@ private:
|
|||
bool mForcePreflight;
|
||||
bool mIsPreflight;
|
||||
bool mLoadTriggeredFromExternal;
|
||||
bool mSkipContentSniffing;
|
||||
|
||||
// Is true if this load was triggered by processing the attributes of the
|
||||
// browsing context container.
|
||||
|
|
|
|||
|
|
@ -367,6 +367,15 @@ interface nsILoadInfo : nsISupports
|
|||
*/
|
||||
[infallible] readonly attribute unsigned long securityMode;
|
||||
|
||||
|
||||
/**
|
||||
* This flag is used for any browsing context where we should not sniff
|
||||
* the content type. E.g if an iframe has the XCTO nosniff header, then
|
||||
* that flag is set to true so we skip content sniffing for that browsing
|
||||
* context.
|
||||
*/
|
||||
[infallible] attribute boolean skipContentSniffing;
|
||||
|
||||
/**
|
||||
* True if this request is embedded in a context that can't be third-party
|
||||
* (i.e. an iframe embedded in a cross-origin parent window). If this is
|
||||
|
|
|
|||
|
|
@ -2129,6 +2129,16 @@ NS_SniffContent(const char *aSnifferType, nsIRequest *aRequest,
|
|||
const uint8_t *aData, uint32_t aLength,
|
||||
nsACString &aSniffedType)
|
||||
{
|
||||
// In case XCTO nosniff was present, we could just skip sniffing here
|
||||
nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
|
||||
if (channel) {
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
|
||||
if (loadInfo->GetSkipContentSniffing()) {
|
||||
aSniffedType.Truncate();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
typedef nsCategoryCache<nsIContentSniffer> ContentSnifferCache;
|
||||
extern ContentSnifferCache* gNetSniffers;
|
||||
extern ContentSnifferCache* gDataSniffers;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue