mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-12 02:31:41 +00:00
Backed out changeset daabf6b822f0 (bug 1321705) for Android bustage. r=backout
This commit is contained in:
parent
0c6dc2ea73
commit
d9d1c52d92
@ -1851,6 +1851,14 @@ 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);
|
||||
|
||||
|
@ -140,6 +140,8 @@ 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 };
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@ -156,6 +158,8 @@ char nsStandardURL::gHostLimitDigits[] = { '/', '\\', '?', '#', 0 };
|
||||
// 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)
|
||||
@ -221,10 +225,13 @@ nsSegmentEncoder::EncodeSegmentCount(const char *str,
|
||||
}
|
||||
}
|
||||
|
||||
// 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, result)) {
|
||||
if (NS_EscapeURL(str + pos, len, mask | escapeFlags, result)) {
|
||||
len = result.Length() - initLen;
|
||||
appended = true;
|
||||
}
|
||||
@ -273,7 +280,7 @@ nsSegmentEncoder::InitUnicodeEncoder()
|
||||
nsSegmentEncoder name(useUTF8 ? nullptr : mOriginCharset.get())
|
||||
|
||||
#define GET_SEGMENT_ENCODER(name) \
|
||||
GET_SEGMENT_ENCODER_INTERNAL(name, true)
|
||||
GET_SEGMENT_ENCODER_INTERNAL(name, gAlwaysEncodeInUTF8)
|
||||
|
||||
#define GET_QUERY_ENCODER(name) \
|
||||
GET_SEGMENT_ENCODER_INTERNAL(name, false)
|
||||
@ -365,6 +372,8 @@ 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
|
||||
@ -1176,6 +1185,18 @@ nsStandardURL::PrefsChanged(nsIPrefBranch *prefs, const char *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
|
||||
if (PREF_CHANGED(NS_NET_PREF_ENABLE_RUST)) {
|
||||
if (GOT_PREF(NS_NET_PREF_ENABLE_RUST, val)) {
|
||||
|
@ -301,6 +301,9 @@ private:
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user