From 90a3e52f3e2ed90c511f1e4dbd1b049374a0176f Mon Sep 17 00:00:00 2001 From: "dbaron%dbaron.org" Date: Mon, 10 Feb 2003 04:14:34 +0000 Subject: [PATCH] Always use the hardcoded fallbacks in GetPreferred so that it works correctly when called with UTF-8 during the loading of mimeTypes.rdf triggered by the loading of mDelegate. r=smontagu sr=bzbarsky a=asa b=190951 git-svn-id: svn://10.0.0.236/trunk@137619 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/intl/uconv/src/nsCharsetAliasImp.cpp | 39 +++++++++++--------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/mozilla/intl/uconv/src/nsCharsetAliasImp.cpp b/mozilla/intl/uconv/src/nsCharsetAliasImp.cpp index 371e62e4de6..8b975f541a3 100644 --- a/mozilla/intl/uconv/src/nsCharsetAliasImp.cpp +++ b/mozilla/intl/uconv/src/nsCharsetAliasImp.cpp @@ -74,24 +74,29 @@ NS_IMETHODIMP nsCharsetAlias2::GetPreferred(const nsAString& aAlias, nsAString& ToLowerCase(aKey); oResult.Truncate(); - //delay loading charsetalias.properties by resolving most freq. aliases + // Delay loading charsetalias.properties by hardcoding the most + // frequent aliases. Note that it's possible to recur in to this + // function *while loading* charsetalias.properties (see bug 190951), + // so we might have an |mDelegate| already that isn't valid yet, but + // the load is guaranteed to be "UTF-8" so things will be OK. + if(aKey.Equals(NS_LITERAL_STRING("utf-8"))) { + oResult = NS_LITERAL_STRING("UTF-8"); + NS_TIMELINE_STOP_TIMER("nsCharsetAlias2:GetPreferred"); + return NS_OK; + } + if(aKey.Equals(NS_LITERAL_STRING("iso-8859-1"))) { + oResult = NS_LITERAL_STRING("ISO-8859-1"); + NS_TIMELINE_STOP_TIMER("nsCharsetAlias2:GetPreferred"); + return NS_OK; + } + if(aKey.Equals(NS_LITERAL_STRING("x-sjis")) || + aKey.Equals(NS_LITERAL_STRING("shift_jis"))) { + oResult = NS_LITERAL_STRING("Shift_JIS"); + NS_TIMELINE_STOP_TIMER("nsCharsetAlias2:GetPreferred"); + return NS_OK; + } + if(!mDelegate) { - if(aKey.Equals(NS_LITERAL_STRING("utf-8"))) { - oResult = NS_LITERAL_STRING("UTF-8"); - NS_TIMELINE_STOP_TIMER("nsCharsetAlias2:GetPreferred"); - return NS_OK; - } - if(aKey.Equals(NS_LITERAL_STRING("iso-8859-1"))) { - oResult = NS_LITERAL_STRING("ISO-8859-1"); - NS_TIMELINE_STOP_TIMER("nsCharsetAlias2:GetPreferred"); - return NS_OK; - } - if(aKey.Equals(NS_LITERAL_STRING("x-sjis")) || - aKey.Equals(NS_LITERAL_STRING("shift_jis"))) { - oResult = NS_LITERAL_STRING("Shift_JIS"); - NS_TIMELINE_STOP_TIMER("nsCharsetAlias2:GetPreferred"); - return NS_OK; - } //load charsetalias.properties string bundle with all remaining aliases // we may need to protect the following section with a lock so we won't call the // 'new nsURLProperties' from two different threads