From d7506637b7da3f31f2b39d2185416d010564ea26 Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Mon, 4 Nov 2013 13:04:02 +0100 Subject: [PATCH] Backed out changeset 88e0c01e2d81 (bug 910192) bustage on a CLOSED TREE --- .../migration/src/SafariProfileMigrator.js | 23 +++ content/html/document/src/nsHTMLDocument.cpp | 26 +++- content/html/document/src/nsHTMLDocument.h | 3 +- docshell/base/nsDocShell.cpp | 2 +- dom/encoding/FallbackEncoding.cpp | 137 ------------------ dom/encoding/FallbackEncoding.h | 72 --------- dom/encoding/Makefile.in | 6 +- dom/encoding/localesfallbacks.properties | 72 --------- dom/encoding/moz.build | 2 - .../tests/CharsetDetectionTests.js | 14 +- layout/build/nsLayoutStatics.cpp | 4 - modules/libpref/src/init/all.js | 2 +- .../converters/nsDirIndexParser.cpp | 19 ++- parser/html/nsHtml5StreamParser.cpp | 10 +- parser/nsCharsetSource.h | 2 +- toolkit/components/search/nsSearchService.js | 3 +- .../global-platform/mac/intl.properties | 2 + .../global-platform/unix/intl.properties | 2 + .../global-platform/win/intl.properties | 2 + .../en-US/chrome/global/intl.properties | 3 +- 20 files changed, 91 insertions(+), 315 deletions(-) delete mode 100644 dom/encoding/FallbackEncoding.cpp delete mode 100644 dom/encoding/FallbackEncoding.h delete mode 100644 dom/encoding/localesfallbacks.properties diff --git a/browser/components/migration/src/SafariProfileMigrator.js b/browser/components/migration/src/SafariProfileMigrator.js index eb1435990c9..6c42f7d6db8 100644 --- a/browser/components/migration/src/SafariProfileMigrator.js +++ b/browser/components/migration/src/SafariProfileMigrator.js @@ -342,6 +342,29 @@ Preferences.prototype = { this._set("WebKitDisplayImagesKey", "permissions.default.image", function(webkitVal) webkitVal ? 1 : 2); + // Default charset migration + this._set("WebKitDefaultTextEncodingName", "intl.charset.default", + function(webkitCharset) { + // We don't support x-mac-korean (see bug 713516), but it mostly matches + // EUC-KR. + if (webkitCharset == "x-mac-korean") + return "EUC-KR"; + + // getCharsetAlias throws if an invalid value is passed in. + try { + return Cc["@mozilla.org/charset-converter-manager;1"]. + getService(Ci.nsICharsetConverterManager). + getCharsetAlias(webkitCharset); + } + catch(ex) { + Cu.reportError("Could not convert webkit charset '" + webkitCharset + + "' to a supported charset"); + } + // Don't set the preference if we could not get the corresponding + // charset. + return undefined; + }); + #ifdef XP_WIN // Cookie-accept policy. // For the OS X version, see WebFoundationCookieBehavior. diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index 23f7876a23e..c04d0205287 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -83,7 +83,6 @@ #include "nsBidiUtils.h" #include "mozilla/dom/EncodingUtils.h" -#include "mozilla/dom/FallbackEncoding.h" #include "nsIEditingSession.h" #include "nsIEditor.h" #include "nsNodeInfoManager.h" @@ -446,13 +445,26 @@ nsHTMLDocument::TryParentCharset(nsIDocShell* aDocShell, } void -nsHTMLDocument::TryFallback(int32_t& aCharsetSource, nsACString& aCharset) +nsHTMLDocument::TryWeakDocTypeDefault(int32_t& aCharsetSource, + nsACString& aCharset) { - if (kCharsetFromFallback <= aCharsetSource) + if (kCharsetFromWeakDocTypeDefault <= aCharsetSource) return; - aCharsetSource = kCharsetFromFallback; - FallbackEncoding::FromLocale(aCharset); + const nsAdoptingCString& defCharset = + Preferences::GetLocalizedCString("intl.charset.default"); + + // Don't let the user break things by setting intl.charset.default to + // not a rough ASCII superset + nsAutoCString canonical; + if (EncodingUtils::FindEncodingForLabel(defCharset, canonical) && + EncodingUtils::IsAsciiCompatible(canonical)) { + aCharset = canonical; + } else { + aCharset.AssignLiteral("windows-1252"); + } + aCharsetSource = kCharsetFromWeakDocTypeDefault; + return; } void @@ -630,7 +642,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand, } if (!IsHTML() || !docShell) { // no docshell for text/html XHR - charsetSource = IsHTML() ? kCharsetFromFallback + charsetSource = IsHTML() ? kCharsetFromWeakDocTypeDefault : kCharsetFromDocTypeDefault; charset.AssignLiteral("UTF-8"); TryChannelCharset(aChannel, charsetSource, charset, executor); @@ -671,7 +683,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand, TryCacheCharset(cachingChan, charsetSource, charset); } - TryFallback(charsetSource, charset); + TryWeakDocTypeDefault(charsetSource, charset); if (wyciwygChannel) { // We know for sure that the parser needs to be using UTF16. diff --git a/content/html/document/src/nsHTMLDocument.h b/content/html/document/src/nsHTMLDocument.h index dd0a4d7c0a6..97fab21066c 100644 --- a/content/html/document/src/nsHTMLDocument.h +++ b/content/html/document/src/nsHTMLDocument.h @@ -313,7 +313,8 @@ protected: nsACString& aCharset); void TryParentCharset(nsIDocShell* aDocShell, int32_t& charsetSource, nsACString& aCharset); - static void TryFallback(int32_t& aCharsetSource, nsACString& aCharset); + static void TryWeakDocTypeDefault(int32_t& aCharsetSource, + nsACString& aCharset); // Override so we can munge the charset on our wyciwyg channel as needed. virtual void SetDocumentCharacterSet(const nsACString& aCharSetID) MOZ_OVERRIDE; diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index b7f782de70a..180ca9cd555 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -1896,7 +1896,7 @@ nsDocShell::GatherCharsetMenuTelemetry() int32_t charsetSource = doc->GetDocumentCharacterSetSource(); switch (charsetSource) { - case kCharsetFromFallback: + case kCharsetFromWeakDocTypeDefault: case kCharsetFromDocTypeDefault: case kCharsetFromCache: case kCharsetFromParentFrame: diff --git a/dom/encoding/FallbackEncoding.cpp b/dom/encoding/FallbackEncoding.cpp deleted file mode 100644 index 55f7692a1e1..00000000000 --- a/dom/encoding/FallbackEncoding.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/dom/FallbackEncoding.h" - -#include "mozilla/dom/EncodingUtils.h" -#include "nsUConvPropertySearch.h" -#include "nsIChromeRegistry.h" -#include "mozilla/Preferences.h" -#include "mozilla/Services.h" - -namespace mozilla { -namespace dom { - -static const char* localesFallbacks[][3] = { -#include "localesfallbacks.properties.h" -}; - -FallbackEncoding* FallbackEncoding::sInstance = nullptr; - -FallbackEncoding::FallbackEncoding() -{ - MOZ_COUNT_CTOR(FallbackEncoding); - MOZ_ASSERT(!FallbackEncoding::sInstance, - "Singleton already exists."); -} - -FallbackEncoding::~FallbackEncoding() -{ - MOZ_COUNT_DTOR(FallbackEncoding); -} - -void -FallbackEncoding::Get(nsACString& aFallback) -{ - if (!mFallback.IsEmpty()) { - aFallback = mFallback; - return; - } - - const nsAdoptingCString& override = - Preferences::GetCString("intl.charset.fallback.override"); - // Don't let the user break things by setting the override to unreasonable - // values via about:config - if (!EncodingUtils::FindEncodingForLabel(override, mFallback) || - !EncodingUtils::IsAsciiCompatible(mFallback) || - mFallback.EqualsLiteral("UTF-8")) { - mFallback.Truncate(); - } - - if (!mFallback.IsEmpty()) { - aFallback = mFallback; - return; - } - - nsAutoCString locale; - nsCOMPtr registry = - mozilla::services::GetXULChromeRegistryService(); - if (registry) { - registry->GetSelectedLocale(NS_LITERAL_CSTRING("global"), locale); - } - - // Let's lower case the string just in case unofficial language packs - // don't stick to conventions. - ToLowerCase(locale); // ASCII lowercasing with CString input! - - // Special case Traditional Chinese before throwing away stuff after the - // language itself. Today we only ship zh-TW, but be defensive about - // possible future values. - if (locale.EqualsLiteral("zh-tw") || - locale.EqualsLiteral("zh-hk") || - locale.EqualsLiteral("zh-mo") || - locale.EqualsLiteral("zh-hant")) { - mFallback.AssignLiteral("Big5"); - aFallback = mFallback; - return; - } - - // Throw away regions and other variants to accommodate weird stuff seen - // in telemetry--apparently unofficial language packs. - int32_t index = locale.FindChar('-'); - if (index >= 0) { - locale.Truncate(index); - } - - if (NS_FAILED(nsUConvPropertySearch::SearchPropertyValue( - localesFallbacks, ArrayLength(localesFallbacks), locale, mFallback))) { - mFallback.AssignLiteral("windows-1252"); - } - - aFallback = mFallback; -} - -void -FallbackEncoding::FromLocale(nsACString& aFallback) -{ - MOZ_ASSERT(FallbackEncoding::sInstance, - "Using uninitialized fallback cache."); - FallbackEncoding::sInstance->Get(aFallback); -} - -// PrefChangedFunc -int -FallbackEncoding::PrefChanged(const char*, void*) -{ - MOZ_ASSERT(FallbackEncoding::sInstance, - "Pref callback called with null fallback cache."); - FallbackEncoding::sInstance->Invalidate(); - return 0; -} - -void -FallbackEncoding::Initialize() -{ - MOZ_ASSERT(!FallbackEncoding::sInstance, - "Initializing pre-existing fallback cache."); - FallbackEncoding::sInstance = new FallbackEncoding; - Preferences::RegisterCallback(FallbackEncoding::PrefChanged, - "intl.charset.fallback.override", - nullptr); - Preferences::RegisterCallback(FallbackEncoding::PrefChanged, - "general.useragent.locale", - nullptr); -} - -void -FallbackEncoding::Shutdown() -{ - MOZ_ASSERT(FallbackEncoding::sInstance, - "Releasing non-existent fallback cache."); - delete FallbackEncoding::sInstance; - FallbackEncoding::sInstance = nullptr; -} - -} // namespace dom -} // namespace mozilla diff --git a/dom/encoding/FallbackEncoding.h b/dom/encoding/FallbackEncoding.h deleted file mode 100644 index eca99627c4d..00000000000 --- a/dom/encoding/FallbackEncoding.h +++ /dev/null @@ -1,72 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_dom_FallbackEncoding_h_ -#define mozilla_dom_FallbackEncoding_h_ - -#include "nsString.h" - -namespace mozilla { -namespace dom { - -class FallbackEncoding -{ -public: - - /** - * Gets the locale-dependent fallback encoding for legacy HTML and plain - * text content. - * - * @param aFallback the outparam for the fallback encoding - */ - static void FromLocale(nsACString& aFallback); - - // public API ends here! - - /** - * Allocate sInstance used by FromLocale(). - * To be called from nsLayoutStatics only. - */ - static void Initialize(); - - /** - * Delete sInstance used by FromLocale(). - * To be called from nsLayoutStatics only. - */ - static void Shutdown(); - -private: - - /** - * The fallback cache. - */ - static FallbackEncoding* sInstance; - - FallbackEncoding(); - ~FallbackEncoding(); - - /** - * Invalidates the cache. - */ - void Invalidate() - { - mFallback.Truncate(); - } - - static int PrefChanged(const char*, void*); - - /** - * Gets the fallback encoding label. - * @param aFallback the fallback encoding - */ - void Get(nsACString& aFallback); - - nsCString mFallback; -}; - -} // dom -} // mozilla - -#endif // mozilla_dom_FallbackEncoding_h_ - diff --git a/dom/encoding/Makefile.in b/dom/encoding/Makefile.in index ff79a6acbd5..2fc86207c3a 100644 --- a/dom/encoding/Makefile.in +++ b/dom/encoding/Makefile.in @@ -9,15 +9,11 @@ LOCAL_INCLUDES = \ include $(topsrcdir)/config/rules.mk EncodingUtils.$(OBJ_SUFFIX): labelsencodings.properties.h -FallbackEncoding.$(OBJ_SUFFIX): localesfallbacks.properties.h PROPS2ARRAYS = $(topsrcdir)/intl/locale/src/props2arrays.py labelsencodings.properties.h: $(PROPS2ARRAYS) labelsencodings.properties $(PYTHON) $^ $@ -localesfallbacks.properties.h: $(PROPS2ARRAYS) localesfallbacks.properties - $(PYTHON) $^ $@ GARBAGE += \ - labelsencodings.properties.h \ - localesfallbacks.properties.h \ + charsetalias.properties.h \ $(NULL) diff --git a/dom/encoding/localesfallbacks.properties b/dom/encoding/localesfallbacks.properties deleted file mode 100644 index e014034124e..00000000000 --- a/dom/encoding/localesfallbacks.properties +++ /dev/null @@ -1,72 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -# This file contains mappings from languages to legacy encodings for languages -# that are associated with legacy encoding other than windows-1252 (except -# Traditional Chinese, which is handled as a special case elsewhere). -# -# The keys are language codes without regions. The values are Gecko-canonical -# encoding labels (not necessarily lower case!). -# -# Rules: -# -# * Avoid editing this file! -# -# * If you do edit this file, be sure to file a spec bug against WHATWG HTML -# to keep this file in sync with -# http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#determining-the-character-encoding -# -# * As an exception to the previous rule, gbk is used instead of GB18030 -# until/unless work on http://encoding.spec.whatwg.org/ shows that the former -# can be treated as an alias of the latter and our decoder implementation -# has been audited to match the spec. -# -# * Use only the language code without a hyphen or anything that would come -# after the hyphen. -# -# * Don't put windows-1252-affiliated languages here. -# -# * Don't put Traditional Chinese here. - -ar=windows-1256 -# https://www.w3.org/Bugs/Public/show_bug.cgi?id=23089 -ba=windows-1251 -# https://www.w3.org/Bugs/Public/show_bug.cgi?id=23089 -be=windows-1251 -bg=windows-1251 -cs=windows-1250 -# https://www.w3.org/Bugs/Public/show_bug.cgi?id=23090 -el=ISO-8859-7 -et=windows-1257 -fa=windows-1256 -he=windows-1255 -hr=windows-1250 -hu=ISO-8859-2 -ja=Shift_JIS -# https://www.w3.org/Bugs/Public/show_bug.cgi?id=23089 -kk=windows-1251 -ko=EUC-KR -ku=windows-1254 -# https://www.w3.org/Bugs/Public/show_bug.cgi?id=23089 -ky=windows-1251 -lt=windows-1257 -lv=windows-1257 -# https://www.w3.org/Bugs/Public/show_bug.cgi?id=23089 -mk=windows-1251 -pl=ISO-8859-2 -ru=windows-1251 -# https://www.w3.org/Bugs/Public/show_bug.cgi?id=23089 -sah=windows-1251 -sk=windows-1250 -sl=ISO-8859-2 -sr=windows-1251 -# https://www.w3.org/Bugs/Public/show_bug.cgi?id=23089 -tg=windows-1251 -th=windows-874 -tr=windows-1254 -# https://www.w3.org/Bugs/Public/show_bug.cgi?id=23089 -tt=windows-1251 -uk=windows-1251 -vi=windows-1258 -zh=gbk diff --git a/dom/encoding/moz.build b/dom/encoding/moz.build index df07c309289..3e8eda067ca 100644 --- a/dom/encoding/moz.build +++ b/dom/encoding/moz.build @@ -10,14 +10,12 @@ MODULE = 'dom' EXPORTS.mozilla.dom += [ 'EncodingUtils.h', - 'FallbackEncoding.h', 'TextDecoder.h', 'TextEncoder.h', ] SOURCES += [ 'EncodingUtils.cpp', - 'FallbackEncoding.cpp', 'TextDecoder.cpp', 'TextEncoder.cpp', ] diff --git a/extensions/universalchardet/tests/CharsetDetectionTests.js b/extensions/universalchardet/tests/CharsetDetectionTests.js index 54dd6651a00..71e219a93bd 100644 --- a/extensions/universalchardet/tests/CharsetDetectionTests.js +++ b/extensions/universalchardet/tests/CharsetDetectionTests.js @@ -45,9 +45,17 @@ function InitDetectorTests() $("testframe").onload = DoDetectionTest; if (gExpectedCharset == "default") { - // No point trying to be generic here, because we have plenty of other - // unit tests that fail if run using a non-windows-1252 locale. - gExpectedCharset = "windows-1252"; + try { + gExpectedCharset = prefService + .getComplexValue("intl.charset.default", + Ci.nsIPrefLocalizedString) + .data; + if (gExpectedCharset == "ISO-8859-1") { + gExpectedCharset = "windows-1252"; + } + } catch (e) { + gExpectedCharset = "windows-1252"; + } } // Get the local directory. This needs to be a file: URI because chrome: diff --git a/layout/build/nsLayoutStatics.cpp b/layout/build/nsLayoutStatics.cpp index f1227c5699e..8b3840d71cd 100644 --- a/layout/build/nsLayoutStatics.cpp +++ b/layout/build/nsLayoutStatics.cpp @@ -50,7 +50,6 @@ #include "nsCrossSiteListenerProxy.h" #include "nsHTMLDNSPrefetch.h" #include "nsHtml5Module.h" -#include "mozilla/dom/FallbackEncoding.h" #include "nsFocusManager.h" #include "nsListControlFrame.h" #include "mozilla/dom/HTMLInputElement.h" @@ -259,7 +258,6 @@ nsLayoutStatics::Initialize() nsContentSink::InitializeStatics(); nsHtml5Module::InitializeStatics(); - mozilla::dom::FallbackEncoding::Initialize(); nsLayoutUtils::Initialize(); nsIPresShell::InitializeStatics(); nsRefreshDriver::InitializeStatics(); @@ -386,8 +384,6 @@ nsLayoutStatics::Shutdown() nsHtml5Module::ReleaseStatics(); - mozilla::dom::FallbackEncoding::Shutdown(); - nsRegion::ShutdownStatic(); NS_ShutdownEventTargetChainRecycler(); diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index ec0f6e3e64a..5bad6ac4835 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -1520,7 +1520,7 @@ pref("intl.charsetmenu.mailview.cache", ""); pref("intl.charsetmenu.composer.cache", ""); pref("intl.charsetmenu.browser.cache.size", 5); pref("intl.charset.detector", "chrome://global/locale/intl.properties"); -pref("intl.charset.fallback.override", ""); +pref("intl.charset.default", "chrome://global-platform/locale/intl.properties"); pref("intl.ellipsis", "chrome://global-platform/locale/intl.properties"); pref("intl.locale.matchOS", false); // fallback charset list for Unicode conversion (converting from Unicode) diff --git a/netwerk/streamconv/converters/nsDirIndexParser.cpp b/netwerk/streamconv/converters/nsDirIndexParser.cpp index 66b8cdb1012..ea115ee8723 100644 --- a/netwerk/streamconv/converters/nsDirIndexParser.cpp +++ b/netwerk/streamconv/converters/nsDirIndexParser.cpp @@ -35,7 +35,24 @@ nsDirIndexParser::Init() { mLineStart = 0; mHasDescription = false; mFormat = nullptr; - mozilla::dom::FallbackEncoding::FromLocale(mEncoding); + + // get default charset to be used for directory listings (fallback to + // ISO-8859-1 if pref is unavailable). + NS_NAMED_LITERAL_CSTRING(kFallbackEncoding, "ISO-8859-1"); + nsXPIDLString defCharset; + nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); + if (prefs) { + nsCOMPtr prefVal; + prefs->GetComplexValue("intl.charset.default", + NS_GET_IID(nsIPrefLocalizedString), + getter_AddRefs(prefVal)); + if (prefVal) + prefVal->ToString(getter_Copies(defCharset)); + } + if (!defCharset.IsEmpty()) + LossyCopyUTF16toASCII(defCharset, mEncoding); // charset labels are always ASCII + else + mEncoding.Assign(kFallbackEncoding); nsresult rv; // XXX not threadsafe diff --git a/parser/html/nsHtml5StreamParser.cpp b/parser/html/nsHtml5StreamParser.cpp index b8708b66315..78018187a85 100644 --- a/parser/html/nsHtml5StreamParser.cpp +++ b/parser/html/nsHtml5StreamParser.cpp @@ -302,7 +302,7 @@ nsHtml5StreamParser::SetupDecodingAndWriteSniffingBufferAndCurrentSegment(const rv = convManager->GetUnicodeDecoder(mCharset.get(), getter_AddRefs(mUnicodeDecoder)); if (rv == NS_ERROR_UCONV_NOCONV) { mCharset.AssignLiteral("windows-1252"); // lower case is the raw form - mCharsetSource = kCharsetFromFallback; + mCharsetSource = kCharsetFromWeakDocTypeDefault; rv = convManager->GetUnicodeDecoderRaw(mCharset.get(), getter_AddRefs(mUnicodeDecoder)); mTreeBuilder->SetDocumentCharset(mCharset, mCharsetSource); } @@ -612,10 +612,10 @@ nsHtml5StreamParser::FinalizeSniffing(const uint8_t* aFromSegment, // can be nul if (mCharsetSource == kCharsetUninitialized) { // Hopefully this case is never needed, but dealing with it anyway mCharset.AssignLiteral("windows-1252"); - mCharsetSource = kCharsetFromFallback; + mCharsetSource = kCharsetFromWeakDocTypeDefault; mTreeBuilder->SetDocumentCharset(mCharset, mCharsetSource); } else if (mMode == LOAD_AS_DATA && - mCharsetSource == kCharsetFromFallback) { + mCharsetSource == kCharsetFromWeakDocTypeDefault) { NS_ASSERTION(mReparseForbidden, "Reparse should be forbidden for XHR"); NS_ASSERTION(!mFeedChardet, "Should not feed chardet for XHR"); NS_ASSERTION(mCharset.EqualsLiteral("UTF-8"), @@ -731,7 +731,7 @@ nsHtml5StreamParser::SniffStreamBytes(const uint8_t* aFromSegment, // nsHTMLDocument is supposed to make sure this does not happen. Let's // deal with this anyway, since who knows how kCharsetFromOtherComponent // is used. - mCharsetSource = kCharsetFromFallback; + mCharsetSource = kCharsetFromWeakDocTypeDefault; } } @@ -981,7 +981,7 @@ nsHtml5StreamParser::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext) // if we failed to get a decoder, there will be fallback, so don't propagate // the error. if (NS_FAILED(rv)) { - mCharsetSource = kCharsetFromFallback; + mCharsetSource = kCharsetFromWeakDocTypeDefault; } return NS_OK; } diff --git a/parser/nsCharsetSource.h b/parser/nsCharsetSource.h index cd555e25e3b..825a362ba67 100644 --- a/parser/nsCharsetSource.h +++ b/parser/nsCharsetSource.h @@ -7,7 +7,7 @@ // note: the value order defines the priority; higher numbers take priority #define kCharsetUninitialized 0 -#define kCharsetFromFallback 1 +#define kCharsetFromWeakDocTypeDefault 1 #define kCharsetFromDocTypeDefault 2 // This and up confident for XHR #define kCharsetFromCache 3 #define kCharsetFromParentFrame 4 diff --git a/toolkit/components/search/nsSearchService.js b/toolkit/components/search/nsSearchService.js index 889fc19bb25..6583c897512 100644 --- a/toolkit/components/search/nsSearchService.js +++ b/toolkit/components/search/nsSearchService.js @@ -564,8 +564,7 @@ function queryCharsetFromCode(aCode) { if (codes[aCode]) return codes[aCode]; - // Don't bother being fancy about what to return in the failure case. - return "windows-1252"; + return getLocalizedPref("intl.charset.default", DEFAULT_QUERY_CHARSET); } function fileCharsetFromCode(aCode) { const codes = [ diff --git a/toolkit/locales/en-US/chrome/global-platform/mac/intl.properties b/toolkit/locales/en-US/chrome/global-platform/mac/intl.properties index 71265a9ef10..93ba2e3a403 100644 --- a/toolkit/locales/en-US/chrome/global-platform/mac/intl.properties +++ b/toolkit/locales/en-US/chrome/global-platform/mac/intl.properties @@ -2,6 +2,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +# moved from navigator/locale/navigator.properties +intl.charset.default=ISO-8859-1 # LOCALIZATION NOTE (intl.ellipsis): Use the unicode ellipsis char, \u2026, # or use "..." if \u2026 doesn't suit traditions in your locale. intl.ellipsis=… diff --git a/toolkit/locales/en-US/chrome/global-platform/unix/intl.properties b/toolkit/locales/en-US/chrome/global-platform/unix/intl.properties index 71265a9ef10..93ba2e3a403 100644 --- a/toolkit/locales/en-US/chrome/global-platform/unix/intl.properties +++ b/toolkit/locales/en-US/chrome/global-platform/unix/intl.properties @@ -2,6 +2,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +# moved from navigator/locale/navigator.properties +intl.charset.default=ISO-8859-1 # LOCALIZATION NOTE (intl.ellipsis): Use the unicode ellipsis char, \u2026, # or use "..." if \u2026 doesn't suit traditions in your locale. intl.ellipsis=… diff --git a/toolkit/locales/en-US/chrome/global-platform/win/intl.properties b/toolkit/locales/en-US/chrome/global-platform/win/intl.properties index 71265a9ef10..93ba2e3a403 100644 --- a/toolkit/locales/en-US/chrome/global-platform/win/intl.properties +++ b/toolkit/locales/en-US/chrome/global-platform/win/intl.properties @@ -2,6 +2,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +# moved from navigator/locale/navigator.properties +intl.charset.default=ISO-8859-1 # LOCALIZATION NOTE (intl.ellipsis): Use the unicode ellipsis char, \u2026, # or use "..." if \u2026 doesn't suit traditions in your locale. intl.ellipsis=… diff --git a/toolkit/locales/en-US/chrome/global/intl.properties b/toolkit/locales/en-US/chrome/global/intl.properties index a144a68aff4..a9e27052919 100644 --- a/toolkit/locales/en-US/chrome/global/intl.properties +++ b/toolkit/locales/en-US/chrome/global/intl.properties @@ -40,7 +40,7 @@ intl.accept_languages=en-US, en # http://mxr.mozilla.org/mozilla/source/browser/components/preferences/fonts.xul font.language.group=x-western -# LOCALIZATION NOTE (intl.charset.detector, intl.charsetmenu.browser.static, intl.charsetmenu.mailedit): +# LOCALIZATION NOTE (intl.charset.detector, intl.charset.default, intl.charsetmenu.browser.static, intl.charsetmenu.mailedit): # For the list of canonical charset values, refer to: # http://mxr.mozilla.org/mozilla-central/source/intl/locale/src/charsetalias.properties # @@ -51,6 +51,7 @@ font.language.group=x-western # Note also that the list of charsets in 'intl.charsetmenu.browser.static' # must always include "UTF-8". intl.charset.detector= +intl.charset.default=ISO-8859-1 intl.charsetmenu.browser.static=ISO-8859-1, UTF-8 intl.charsetmenu.mailedit=ISO-8859-1, ISO-8859-15, ISO-8859-6, armscii-8, ISO-8859-13, ISO-8859-14, ISO-8859-2, GB2312, GB18030, Big5, KOI8-R, windows-1251, KOI8-U, ISO-8859-7, ISO-8859-8-I, windows-1255, ISO-2022-JP, EUC-KR, ISO-8859-10, ISO-8859-3, TIS-620, ISO-8859-9, UTF-8, VISCII