Bug 1321705 - Remove "network.standard-url.(escape|encode)-utf8". r=valentin.gosu
MozReview-Commit-ID: D6fRD9ElrBd
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -1846,24 +1846,16 @@ pref("network.dns.disablePrefetch", fals
pref("network.dns.blockDotOnion", true);
// These domains are treated as localhost equivalent
pref("network.dns.localDomains", "");
// Contols whether or not "localhost" should resolve when offline
pref("network.dns.offline-localhost", true);
-// This preference controls whether or not URLs with UTF-8 characters are
-// escaped. Set this preference to TRUE for strict RFC2396 conformance.
-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", true);
-
// The maximum allowed length for a URL - 1MB default
pref("network.standard-url.max-length", 1048576);
// The preference controls if the rust URL parser is run in parallel with the
// C++ implementation. Requires restart for changes to take effect.
pref("network.standard-url.enable-rust", false);
// Idle timeout for ftp control connections - 5 minute default
--- a/netwerk/base/nsStandardURL.cpp
+++ b/netwerk/base/nsStandardURL.cpp
@@ -135,36 +135,32 @@ using namespace mozilla::ipc;
namespace mozilla {
namespace net {
static NS_DEFINE_CID(kThisImplCID, NS_THIS_STANDARDURL_IMPL_CID);
static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID);
nsIIDNService *nsStandardURL::gIDN = nullptr;
bool nsStandardURL::gInitialized = false;
-bool nsStandardURL::gEscapeUTF8 = true;
-bool nsStandardURL::gAlwaysEncodeInUTF8 = true;
char nsStandardURL::gHostLimitDigits[] = { '/', '\\', '?', '#', 0 };
//----------------------------------------------------------------------------
#define ENSURE_MUTABLE() \
PR_BEGIN_MACRO \
if (!mMutable) { \
NS_WARNING("attempt to modify an immutable nsStandardURL"); \
return NS_ERROR_ABORT; \
} \
PR_END_MACRO
//----------------------------------------------------------------------------
// nsStandardURL::nsPrefObserver
//----------------------------------------------------------------------------
-#define NS_NET_PREF_ESCAPEUTF8 "network.standard-url.escape-utf8"
-#define NS_NET_PREF_ALWAYSENCODEINUTF8 "network.standard-url.encode-utf8"
#define NS_NET_PREF_ENABLE_RUST "network.standard-url.enable-rust"
NS_IMPL_ISUPPORTS(nsStandardURL::nsPrefObserver, nsIObserver)
NS_IMETHODIMP nsStandardURL::
nsPrefObserver::Observe(nsISupports *subject,
const char *topic,
const char16_t *data)
@@ -220,23 +216,20 @@ nsSegmentEncoder::EncodeSegmentCount(con
str = encBuf.get();
pos = 0;
len = encBuf.Length();
}
// else some failure occurred... assume UTF-8 is ok.
}
}
- // escape per RFC2396 unless UTF-8 and allowed by preferences
- int16_t escapeFlags = (gEscapeUTF8 || mEncoder) ? 0 : esc_OnlyASCII;
-
uint32_t initLen = result.Length();
// now perform any required escaping
- if (NS_EscapeURL(str + pos, len, mask | escapeFlags, result)) {
+ if (NS_EscapeURL(str + pos, len, mask, result)) {
len = result.Length() - initLen;
appended = true;
}
else if (str == encBuf.get()) {
result += encBuf; // append only!!
len = encBuf.Length();
appended = true;
}
@@ -275,17 +268,17 @@ nsSegmentEncoder::InitUnicodeEncoder()
mEncoder = MakeUnique<nsNCRFallbackEncoderWrapper>(encoding);
return true;
}
#define GET_SEGMENT_ENCODER_INTERNAL(name, useUTF8) \
nsSegmentEncoder name(useUTF8 ? nullptr : mOriginCharset.get())
#define GET_SEGMENT_ENCODER(name) \
- GET_SEGMENT_ENCODER_INTERNAL(name, gAlwaysEncodeInUTF8)
+ GET_SEGMENT_ENCODER_INTERNAL(name, true)
#define GET_QUERY_ENCODER(name) \
GET_SEGMENT_ENCODER_INTERNAL(name, false)
//----------------------------------------------------------------------------
// nsStandardURL <public>
//----------------------------------------------------------------------------
@@ -367,18 +360,16 @@ DumpLeakedURLs::~DumpLeakedURLs()
#endif
void
nsStandardURL::InitGlobalObjects()
{
nsCOMPtr<nsIPrefBranch> prefBranch( do_GetService(NS_PREFSERVICE_CONTRACTID) );
if (prefBranch) {
nsCOMPtr<nsIObserver> obs( new nsPrefObserver() );
- prefBranch->AddObserver(NS_NET_PREF_ESCAPEUTF8, obs.get(), false);
- prefBranch->AddObserver(NS_NET_PREF_ALWAYSENCODEINUTF8, obs.get(), false);
#ifdef MOZ_RUST_URLPARSE
prefBranch->AddObserver(NS_NET_PREF_ENABLE_RUST, obs.get(), false);
#endif
PrefsChanged(prefBranch, nullptr);
}
#ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN
PR_INIT_CLIST(&gAllURLs);
@@ -1173,36 +1164,23 @@ nsStandardURL::WriteSegment(nsIBinaryOut
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
/* static */ void
nsStandardURL::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
{
- bool val;
-
LOG(("nsStandardURL::PrefsChanged [pref=%s]\n", pref));
#define PREF_CHANGED(p) ((pref == nullptr) || !strcmp(pref, p))
#define GOT_PREF(p, b) (NS_SUCCEEDED(prefs->GetBoolPref(p, &b)))
- if (PREF_CHANGED(NS_NET_PREF_ESCAPEUTF8)) {
- if (GOT_PREF(NS_NET_PREF_ESCAPEUTF8, val))
- gEscapeUTF8 = val;
- LOG(("escape UTF-8 %s\n", gEscapeUTF8 ? "enabled" : "disabled"));
- }
-
- if (PREF_CHANGED(NS_NET_PREF_ALWAYSENCODEINUTF8)) {
- if (GOT_PREF(NS_NET_PREF_ALWAYSENCODEINUTF8, val))
- gAlwaysEncodeInUTF8 = val;
- LOG(("encode in UTF-8 %s\n", gAlwaysEncodeInUTF8 ? "enabled" : "disabled"));
- }
-
#ifdef MOZ_RUST_URLPARSE
+ bool val;
if (PREF_CHANGED(NS_NET_PREF_ENABLE_RUST)) {
if (GOT_PREF(NS_NET_PREF_ENABLE_RUST, val)) {
gRustEnabled = val;
}
LOG(("Rust parser %s\n", gRustEnabled ? "enabled" : "disabled"));
}
#endif // MOZ_RUST_URLPARSE
--- a/netwerk/base/nsStandardURL.h
+++ b/netwerk/base/nsStandardURL.h
@@ -297,19 +297,16 @@ private:
uint32_t mMutable : 1; // nsIStandardURL::mutable
uint32_t mSupportsFileURL : 1; // QI to nsIFileURL?
// global objects. don't use COMPtr as its destructor will cause a
// coredump if we leak it.
static nsIIDNService *gIDN;
static char gHostLimitDigits[];
static bool gInitialized;
- static bool gEscapeUTF8;
- static bool gAlwaysEncodeInUTF8;
- static bool gEncodeQueryInUTF8;
public:
#ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN
PRCList mDebugCList;
void PrintSpec() const { printf(" %s\n", mSpec.get()); }
#endif
#ifdef MOZ_RUST_URLPARSE