1
0
mirror of https://github.com/roytam1/UXP.git synced 2026-05-26 13:58:49 +00:00

Revert "Issue #2258 - Part 2: Move XCTO:nosniff check into sniffers."

This reverts commit 51e1650d42b2c033d5d55750b4ea497053524c93.
This commit is contained in:
Moonchild
2025-09-23 18:17:45 +02:00
committed by roytam1
parent 2d4d48db72
commit 73c9c1dd73
5 changed files with 14 additions and 17 deletions
-7
View File
@@ -2489,13 +2489,6 @@ imgLoader::GetMIMETypeFromContent(nsIRequest* aRequest,
uint32_t aLength,
nsACString& aContentType)
{
nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest));
if (channel) {
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
if (loadInfo->GetSkipContentSniffing()) {
return NS_ERROR_NOT_AVAILABLE;
}
}
return GetMimeTypeFromContent((const char*)aContents, aLength, aContentType);
}
+10
View File
@@ -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;
+1 -1
View File
@@ -1106,7 +1106,7 @@ ProcessXCTO(nsIURI* aURI, nsHttpResponseHead* aResponseHead, nsILoadInfo* aLoadI
policyType == nsIContentPolicy::TYPE_SUBDOCUMENT) {
// If the header XCTO nosniff is set for any browsing context, then
// we set the skipContentSniffing flag on the Loadinfo. Within
// GetMIMETypeFromContent we then bail early and do not do any sniffing.
// NS_SniffContent we then bail early and do not do any sniffing.
aLoadInfo->SetSkipContentSniffing(true);
return NS_OK;
}
@@ -317,11 +317,9 @@ nsUnknownDecoder::GetMIMETypeFromContent(nsIRequest* aRequest,
{
// Note: This is only used by sniffer, therefore we do not need to lock anything here.
nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest));
if (channel) {
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
if (loadInfo->GetSkipContentSniffing()) {
return NS_ERROR_NOT_AVAILABLE;
}
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
if (loadInfo->GetSkipContentSniffing()) {
return NS_OK;
}
mBuffer = const_cast<char*>(reinterpret_cast<const char*>(aData));
mBufferLen = aLength;
@@ -138,10 +138,6 @@ nsMediaSniffer::GetMIMETypeFromContent(nsIRequest* aRequest,
nsACString& aSniffedType) {
nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
if (channel) {
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
if (loadInfo->GetSkipContentSniffing()) {
return NS_ERROR_NOT_AVAILABLE;
}
nsLoadFlags loadFlags = 0;
channel->GetLoadFlags(&loadFlags);
if (!(loadFlags & nsIChannel::LOAD_MEDIA_SNIFFER_OVERRIDES_CONTENT_TYPE)) {