Bug 1428473 Support X-Content-Type-Options: nosniff when navigating r=ckerschb,dragana,alchen

***
Apply Requested Revision

Differential Revision: https://phabricator.services.mozilla.com/D33959
This commit is contained in:
Sebastian Streich
2019-07-31 16:59:53 +00:00
parent 5c45b2d2dd
commit e8e47a5844
15 changed files with 279 additions and 6 deletions

View File

@@ -190,7 +190,8 @@ nsHtml5StreamParser::nsHtml5StreamParser(nsHtml5TreeOpExecutor* aExecutor,
mFlushTimerMutex("nsHtml5StreamParser mFlushTimerMutex"),
mFlushTimerArmed(false),
mFlushTimerEverFired(false),
mMode(aMode) {
mMode(aMode),
mSkipContentSniffing(false) {
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
#ifdef DEBUG
mAtomTable.SetPermittedLookupEventTarget(mEventTarget);
@@ -631,7 +632,7 @@ nsresult nsHtml5StreamParser::FinalizeSniffing(Span<const uint8_t> aFromSegment,
}
// meta scan failed.
if (mCharsetSource < kCharsetFromMetaPrescan) {
if (!mSkipContentSniffing && mCharsetSource < kCharsetFromMetaPrescan) {
// Check for BOMless UTF-16 with Basic
// Latin content for compat with IE. See bug 631751.
SniffBOMlessUTF16BasicLatin(aFromSegment.To(aCountToSniffingLimit));
@@ -662,6 +663,7 @@ nsresult nsHtml5StreamParser::SniffStreamBytes(
Span<const uint8_t> aFromSegment) {
NS_ASSERTION(IsParserThread(), "Wrong thread!");
nsresult rv = NS_OK;
// mEncoding and mCharsetSource potentially have come from channel or higher
// by now. If we find a BOM, SetupDecodingFromBom() will overwrite them.
// If we don't find a BOM, the previously set values of mEncoding and
@@ -957,6 +959,13 @@ nsresult nsHtml5StreamParser::OnStartRequest(nsIRequest* aRequest) {
mObserver->OnStartRequest(aRequest);
}
mRequest = aRequest;
nsCOMPtr<nsIChannel> myChannel(do_QueryInterface(aRequest));
nsCOMPtr<nsILoadInfo> loadInfo = myChannel->LoadInfo();
mSkipContentSniffing = loadInfo->GetSkipContentSniffing();
if (mSkipContentSniffing) {
mFeedChardet = false;
}
mStreamState = STREAM_BEING_READ;