From fdc52760ee0431f4af3ef7ad937e3f2cf3047a20 Mon Sep 17 00:00:00 2001 From: Masatoshi Kimura Date: Wed, 9 Nov 2011 16:02:14 +0100 Subject: [PATCH] Bug 647403 - Add a pref for CreateFixupURI to use UTF-8; r=bz --- docshell/base/nsDefaultURIFixup.cpp | 7 ++++--- modules/libpref/src/init/all.js | 5 +---- netwerk/base/src/nsStandardURL.cpp | 12 +----------- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/docshell/base/nsDefaultURIFixup.cpp b/docshell/base/nsDefaultURIFixup.cpp index 30d98fade92..80475f9f5da 100644 --- a/docshell/base/nsDefaultURIFixup.cpp +++ b/docshell/base/nsDefaultURIFixup.cpp @@ -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 diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index eebc6d0d691..40b65b03717 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -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); diff --git a/netwerk/base/src/nsStandardURL.cpp b/netwerk/base/src/nsStandardURL.cpp index df06b767c83..573c712de04 100644 --- a/netwerk/base/src/nsStandardURL.cpp +++ b/netwerk/base/src/nsStandardURL.cpp @@ -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 @@ -350,7 +347,6 @@ nsStandardURL::InitGlobalObjects() nsCOMPtr 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 }