Bug 234628 part 1 - Make the BOM take precedence over manual encoding overrides. r=smaug.

This commit is contained in:
Henri Sivonen 2013-01-18 16:27:03 +02:00
parent fa8dda9057
commit 6e6ffe477c
2 changed files with 10 additions and 12 deletions

View File

@ -938,17 +938,17 @@ nsHtml5StreamParser::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
} }
nsCOMPtr<nsIWyciwygChannel> wyciwygChannel(do_QueryInterface(mRequest)); nsCOMPtr<nsIWyciwygChannel> wyciwygChannel(do_QueryInterface(mRequest));
if (wyciwygChannel) { 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) {
// we aren't ready to commit to an encoding yet // we aren't ready to commit to an encoding yet
// leave converter uninstantiated for now // leave converter uninstantiated for now
return NS_OK; return NS_OK;
} }
// We are reloading a document.open()ed doc.
mReparseForbidden = true;
mFeedChardet = false;
// Instantiate the converter here to avoid BOM sniffing.
nsCOMPtr<nsICharsetConverterManager> convManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv); nsCOMPtr<nsICharsetConverterManager> convManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = convManager->GetUnicodeDecoder(mCharset.get(), getter_AddRefs(mUnicodeDecoder)); rv = convManager->GetUnicodeDecoder(mCharset.get(), getter_AddRefs(mUnicodeDecoder));

View File

@ -19,10 +19,8 @@
#define kCharsetFromIrreversibleAutoDetection 10 #define kCharsetFromIrreversibleAutoDetection 10
#define kCharsetFromChannel 11 #define kCharsetFromChannel 11
#define kCharsetFromOtherComponent 12 #define kCharsetFromOtherComponent 12
#define kCharsetFromByteOrderMark 13 #define kCharsetFromParentForced 13 // propagates to child frames
// Levels below here will be forced onto childframes too #define kCharsetFromUserForced 14 // propagates to child frames
#define kCharsetFromParentForced 14 #define kCharsetFromByteOrderMark 15
#define kCharsetFromUserForced 15
#define kCharsetFromPreviousLoading 16
#endif /* nsCharsetSource_h_ */ #endif /* nsCharsetSource_h_ */