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

This fixes a regression for the JSON viewer from part 1 as it relies on
sniffing to prettify (and should carve out the exception even if `nosniff`
headers are sent).
No real functional changes otherwise. Just catering to a corner case.
This commit is contained in:
Moonchild 2025-08-12 17:01:36 +02:00 • committed by roytam1
commit cca20ae131
5 changed files with 17 additions and 14 deletions

View file

@ -2489,6 +2489,13 @@ 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);
}