mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 15:58:39 +09:00
Issue #2258 - Part 3: Allow sniffing with XCTO:nosniff + empty MIME type.
This moves the checking code back to NS_SniffContent and specifically checks requests for either: - Empty `Content-type` header, OR - A known JSON MIME type If present, sniffing is allowed despite `nosniff` because in the first case this is webmaster error (conflicting `nosniff` without MIME type would always fail, so sniff it), and in the second case we need this carveout or our json viewer will break.
This commit is contained in:
parent
cca20ae131
commit
707c3e3fa8
5 changed files with 31 additions and 35 deletions
|
|
@ -316,13 +316,6 @@ nsUnknownDecoder::GetMIMETypeFromContent(nsIRequest* aRequest,
|
|||
nsACString& type)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
mBuffer = const_cast<char*>(reinterpret_cast<const char*>(aData));
|
||||
mBufferLen = aLength;
|
||||
DetermineContentType(aRequest);
|
||||
|
|
@ -353,11 +346,6 @@ bool nsUnknownDecoder::AllowSniffing(nsIRequest* aRequest)
|
|||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
|
||||
if (loadInfo->GetSkipContentSniffing()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isLocalFile = false;
|
||||
if (NS_FAILED(uri->SchemeIs("file", &isLocalFile)) || isLocalFile) {
|
||||
return false;
|
||||
|
|
@ -405,13 +393,6 @@ void nsUnknownDecoder::DetermineContentType(nsIRequest* aRequest)
|
|||
if (!mContentType.IsEmpty()) return;
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> channel(do_QueryInterface(aRequest));
|
||||
if (channel) {
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
|
||||
if (loadInfo->GetSkipContentSniffing()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const char* testData = mBuffer;
|
||||
uint32_t testDataLen = mBufferLen;
|
||||
// Check if data are compressed.
|
||||
|
|
@ -583,9 +564,6 @@ bool nsUnknownDecoder::SniffURI(nsIRequest* aRequest)
|
|||
{
|
||||
nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest));
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
|
||||
if (loadInfo->GetSkipContentSniffing()) {
|
||||
return false;
|
||||
}
|
||||
nsCOMPtr<nsIMIMEService> mimeService(do_GetService("@mozilla.org/mime;1"));
|
||||
if (mimeService) {
|
||||
nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue