From 7f2f8a25e2e08843afd3be915544692ff42e4348 Mon Sep 17 00:00:00 2001 From: Henri Sivonen Date: Fri, 18 Jan 2013 16:27:03 +0200 Subject: [PATCH] Bug 234628 part 1 - Make the BOM take precedence over manual encoding overrides. r=smaug. --- parser/html/nsHtml5StreamParser.cpp | 14 +++++++------- parser/nsCharsetSource.h | 8 +++----- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/parser/html/nsHtml5StreamParser.cpp b/parser/html/nsHtml5StreamParser.cpp index 9d110e7d142a..13400c66a68c 100644 --- a/parser/html/nsHtml5StreamParser.cpp +++ b/parser/html/nsHtml5StreamParser.cpp @@ -938,17 +938,17 @@ nsHtml5StreamParser::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext) } nsCOMPtr wyciwygChannel(do_QueryInterface(mRequest)); - if (wyciwygChannel) { - mReparseForbidden = true; - mFeedChardet = false; - // If we are reloading a document.open()ed doc, fall through to converter - // instantiation here and avoid BOM sniffing. - } else if (mCharsetSource < kCharsetFromParentForced) { + if (!wyciwygChannel) { // we aren't ready to commit to an encoding yet // leave converter uninstantiated for now return NS_OK; } - + + // We are reloading a document.open()ed doc. + mReparseForbidden = true; + mFeedChardet = false; + + // Instantiate the converter here to avoid BOM sniffing. nsCOMPtr convManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); rv = convManager->GetUnicodeDecoder(mCharset.get(), getter_AddRefs(mUnicodeDecoder)); diff --git a/parser/nsCharsetSource.h b/parser/nsCharsetSource.h index feee1a19f718..ac6264e39d97 100644 --- a/parser/nsCharsetSource.h +++ b/parser/nsCharsetSource.h @@ -19,10 +19,8 @@ #define kCharsetFromIrreversibleAutoDetection 10 #define kCharsetFromChannel 11 #define kCharsetFromOtherComponent 12 -#define kCharsetFromByteOrderMark 13 -// Levels below here will be forced onto childframes too -#define kCharsetFromParentForced 14 -#define kCharsetFromUserForced 15 -#define kCharsetFromPreviousLoading 16 +#define kCharsetFromParentForced 13 // propagates to child frames +#define kCharsetFromUserForced 14 // propagates to child frames +#define kCharsetFromByteOrderMark 15 #endif /* nsCharsetSource_h_ */