From 19493b9eec78e4be6db81b342dc869b3df7ce70a Mon Sep 17 00:00:00 2001 From: "darin%meer.net" Date: Wed, 12 Jan 2005 21:45:42 +0000 Subject: [PATCH] fixes bug 261929 "Consider sending urls in UTF-8 by default (images/links with non-ASCII chacters not displayed)" r=jshin sr=bzbarsky --- modules/libpref/src/init/all.js | 10 ++++----- netwerk/base/src/nsStandardURL.cpp | 36 ++++++++++++++---------------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 62d2e1f0280..9f177f0a991 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -568,7 +568,7 @@ pref("network.standard-url.escape-utf8", true); // This preference controls whether or not URLs are always encoded and sent as // UTF-8. -pref("network.standard-url.encode-utf8", false); +pref("network.standard-url.encode-utf8", true); // Idle timeout for ftp control connections - 5 minute default pref("network.ftp.idleConnectionTimeout", 300); @@ -601,10 +601,10 @@ pref("network.negotiate-auth.allow-proxies", true); // The following prefs are used to enable automatic use of the operating // system's NTLM implementation to silently authenticate the user with their -// Window's domain logon. By default, this is enabled for proxy servers. -// The trusted-uris pref follows the format of the trusted-uris pref for -// negotiate authentication. -pref("network.automatic-ntlm-auth.allow-proxies", true); +// Window's domain logon. By default, this is disabled for proxy servers due +// to bug 256949. The trusted-uris pref follows the format of the trusted-uris +// pref for negotiate authentication. +pref("network.automatic-ntlm-auth.allow-proxies", false); pref("network.automatic-ntlm-auth.trusted-uris", ""); diff --git a/netwerk/base/src/nsStandardURL.cpp b/netwerk/base/src/nsStandardURL.cpp index 2b29426c5b0..6a470d0c59c 100644 --- a/netwerk/base/src/nsStandardURL.cpp +++ b/netwerk/base/src/nsStandardURL.cpp @@ -62,7 +62,7 @@ nsIIDNService *nsStandardURL::gIDNService = nsnull; nsICharsetConverterManager *nsStandardURL::gCharsetMgr = nsnull; PRBool nsStandardURL::gInitialized = PR_FALSE; PRBool nsStandardURL::gEscapeUTF8 = PR_TRUE; -PRBool nsStandardURL::gAlwaysEncodeInUTF8 = PR_FALSE; +PRBool nsStandardURL::gAlwaysEncodeInUTF8 = PR_TRUE; #if defined(PR_LOGGING) // @@ -180,7 +180,7 @@ nsSegmentEncoder::EncodeSegmentCount(const char *str, // null or the empty string then the origin charset is UTF-8 and there // is nothing to do. nsCAutoString encBuf; - if (!nsCRT::IsAscii(str + pos, len) && mCharset && *mCharset) { + if (mCharset && *mCharset && !nsCRT::IsAscii(str + pos, len)) { // we have to encode this segment if (mEncoder || InitUnicodeEncoder()) { NS_ConvertUTF8toUCS2 ucsBuf(Substring(str + pos, str + pos + len)); @@ -249,7 +249,7 @@ nsSegmentEncoder::InitUnicodeEncoder() } #define GET_SEGMENT_ENCODER(name) \ - nsSegmentEncoder name(mOriginCharset.get()) + nsSegmentEncoder name(gAlwaysEncodeInUTF8 ? nsnull : mOriginCharset.get()) //---------------------------------------------------------------------------- // nsStandardURL @@ -2413,26 +2413,24 @@ nsStandardURL::Init(PRUint32 urlType, mOriginCharset.Truncate(); - if (!gAlwaysEncodeInUTF8) { - if (charset == nsnull || *charset == '\0') { - // check if baseURI provides an origin charset and use that. - if (baseURI) - baseURI->GetOriginCharset(mOriginCharset); + if (charset == nsnull || *charset == '\0') { + // check if baseURI provides an origin charset and use that. + if (baseURI) + baseURI->GetOriginCharset(mOriginCharset); - // URI can't be encoded in UTF-16, UTF-16BE, UTF-16LE, UTF-32, - // UTF-32-LE, UTF-32LE, UTF-32BE (yet?). Truncate mOriginCharset if - // it starts with "utf" (since an empty mOriginCharset implies - // UTF-8, this is safe even if mOriginCharset is UTF-8). + // URI can't be encoded in UTF-16, UTF-16BE, UTF-16LE, UTF-32, + // UTF-32-LE, UTF-32LE, UTF-32BE (yet?). Truncate mOriginCharset if + // it starts with "utf" (since an empty mOriginCharset implies + // UTF-8, this is safe even if mOriginCharset is UTF-8). - if (mOriginCharset.Length() > 3 && - IsUTFCharset(mOriginCharset.get())) { - mOriginCharset.Truncate(); - } - } - else if (!IsUTFCharset(charset)) { - mOriginCharset = charset; + if (mOriginCharset.Length() > 3 && + IsUTFCharset(mOriginCharset.get())) { + mOriginCharset.Truncate(); } } + else if (!IsUTFCharset(charset)) { + mOriginCharset = charset; + } if (baseURI) { PRUint32 start, end;