Bug 647403 - Add a pref for CreateFixupURI to use UTF-8; r=bz

This commit is contained in:
Masatoshi Kimura 2011-11-09 16:02:14 +01:00
parent 1fc8a93bfb
commit fdc52760ee
3 changed files with 6 additions and 18 deletions

View File

@ -234,9 +234,10 @@ nsDefaultURIFixup::CreateFixupURI(const nsACString& aStringURI, PRUint32 aFixupF
// For these protocols, use system charset instead of the default UTF-8,
// if the URI is non ASCII.
bool bAsciiURI = IsASCII(uriString);
bool useUTF8 = (aFixupFlags & FIXUP_FLAG_USE_UTF8) ||
Preferences::GetBool("browser.fixup.use-utf8", false);
bool bUseNonDefaultCharsetForURI =
!bAsciiURI &&
!(aFixupFlags & FIXUP_FLAG_USE_UTF8) &&
!bAsciiURI && !useUTF8 &&
(scheme.IsEmpty() ||
scheme.LowerCaseEqualsLiteral("http") ||
scheme.LowerCaseEqualsLiteral("https") ||
@ -323,7 +324,7 @@ nsDefaultURIFixup::CreateFixupURI(const nsACString& aStringURI, PRUint32 aFixupF
uriString.Assign(NS_LITERAL_CSTRING("http://") + uriString);
// For ftp & http, we want to use system charset.
if (!bAsciiURI && !(aFixupFlags & FIXUP_FLAG_USE_UTF8))
if (!bAsciiURI && !useUTF8)
bUseNonDefaultCharsetForURI = true;
} // end if checkprotocol

View File

@ -319,6 +319,7 @@ pref("browser.fixup.alternate.enabled", true);
pref("browser.fixup.alternate.prefix", "www.");
pref("browser.fixup.alternate.suffix", ".com");
pref("browser.fixup.hide_user_pass", true);
pref("browser.fixup.use-utf8", false);
// Location Bar AutoComplete
pref("browser.urlbar.autocomplete.enabled", true);
@ -989,10 +990,6 @@ pref("network.standard-url.escape-utf8", true);
// UTF-8.
pref("network.standard-url.encode-utf8", true);
// This preference controls whether or not queries are encoded and sent as
// UTF-8.
pref("network.standard-url.encode-query-utf8", false);
// Idle timeout for ftp control connections - 5 minute default
pref("network.ftp.idleConnectionTimeout", 300);

View File

@ -67,7 +67,6 @@ nsICharsetConverterManager *nsStandardURL::gCharsetMgr = nsnull;
bool nsStandardURL::gInitialized = false;
bool nsStandardURL::gEscapeUTF8 = true;
bool nsStandardURL::gAlwaysEncodeInUTF8 = true;
bool nsStandardURL::gEncodeQueryInUTF8 = true;
#if defined(PR_LOGGING)
//
@ -144,7 +143,6 @@ end:
#define NS_NET_PREF_ESCAPEUTF8 "network.standard-url.escape-utf8"
#define NS_NET_PREF_ENABLEIDN "network.enableIDN"
#define NS_NET_PREF_ALWAYSENCODEINUTF8 "network.standard-url.encode-utf8"
#define NS_NET_PREF_ENCODEQUERYINUTF8 "network.standard-url.encode-query-utf8"
NS_IMPL_ISUPPORTS1(nsStandardURL::nsPrefObserver, nsIObserver)
@ -273,8 +271,7 @@ nsSegmentEncoder::InitUnicodeEncoder()
GET_SEGMENT_ENCODER_INTERNAL(name, gAlwaysEncodeInUTF8)
#define GET_QUERY_ENCODER(name) \
GET_SEGMENT_ENCODER_INTERNAL(name, gAlwaysEncodeInUTF8 && \
gEncodeQueryInUTF8)
GET_SEGMENT_ENCODER_INTERNAL(name, false)
//----------------------------------------------------------------------------
// nsStandardURL <public>
@ -350,7 +347,6 @@ nsStandardURL::InitGlobalObjects()
nsCOMPtr<nsIObserver> obs( new nsPrefObserver() );
prefBranch->AddObserver(NS_NET_PREF_ESCAPEUTF8, obs.get(), false);
prefBranch->AddObserver(NS_NET_PREF_ALWAYSENCODEINUTF8, obs.get(), false);
prefBranch->AddObserver(NS_NET_PREF_ENCODEQUERYINUTF8, obs.get(), false);
prefBranch->AddObserver(NS_NET_PREF_ENABLEIDN, obs.get(), false);
PrefsChanged(prefBranch, nsnull);
@ -956,12 +952,6 @@ nsStandardURL::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
gAlwaysEncodeInUTF8 = val;
LOG(("encode in UTF-8 %s\n", gAlwaysEncodeInUTF8 ? "enabled" : "disabled"));
}
if (PREF_CHANGED(NS_NET_PREF_ENCODEQUERYINUTF8)) {
if (GOT_PREF(NS_NET_PREF_ENCODEQUERYINUTF8, val))
gEncodeQueryInUTF8 = val;
LOG(("encode query in UTF-8 %s\n", gEncodeQueryInUTF8 ? "enabled" : "disabled"));
}
#undef PREF_CHANGED
#undef GOT_PREF
}