From af3700e48e0207392dce3c58364a58da4c8cc12a Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Fri, 1 Feb 2002 21:36:00 +0000 Subject: [PATCH] Don't let an empty intl.charset.default pref set the document charset to the empty string. Fall back to ISO-8859-1 in the script loader if there is no other charset set. Bug 118404, r=harishd, sr=jst --- content/base/src/nsScriptLoader.cpp | 5 +++++ content/html/document/src/nsHTMLDocument.cpp | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/content/base/src/nsScriptLoader.cpp b/content/base/src/nsScriptLoader.cpp index 0808104d890a..cd621de819b4 100644 --- a/content/base/src/nsScriptLoader.cpp +++ b/content/base/src/nsScriptLoader.cpp @@ -691,6 +691,11 @@ nsScriptLoader::OnStreamComplete(nsIStreamLoader* aLoader, NS_ASSERTION(NS_SUCCEEDED(rv), "Could not get document charset!"); + if (characterSet.IsEmpty()) { + // fall back to ISO-8851-1, see bug 118404 + characterSet = NS_LITERAL_STRING("ISO-8859-1"); + } + nsCOMPtr charsetConv = do_GetService(kCharsetConverterManagerCID, &rv); diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index 38fc1d01706e..4135b1f2febc 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -679,11 +679,11 @@ nsHTMLDocument::TryWeakDocTypeDefault(PRInt32& aCharsetSource, if (prefs) { nsXPIDLString defCharset; nsresult rv = prefs->GetLocalizedUnicharPref("intl.charset.default", getter_Copies(defCharset)); - if (NS_SUCCEEDED(rv)) { + if (NS_SUCCEEDED(rv) && !defCharset.IsEmpty()) { aCharset.Assign(defCharset); + aCharsetSource = kCharsetFromWeakDocTypeDefault; } } - aCharsetSource = kCharsetFromWeakDocTypeDefault; return PR_TRUE; }