зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1093611 - AnchorElement.hash should be the encoded version of the href attribute's fragment r=smaug
This commit is contained in:
Родитель
0f0c68cbea
Коммит
95adf859fe
|
@ -441,8 +441,10 @@ Link::GetHash(nsAString &_hash, ErrorResult& aError)
|
|||
nsAutoCString ref;
|
||||
nsresult rv = uri->GetRef(ref);
|
||||
if (NS_SUCCEEDED(rv) && !ref.IsEmpty()) {
|
||||
NS_UnescapeURL(ref); // XXX may result in random non-ASCII bytes!
|
||||
_hash.Assign(char16_t('#'));
|
||||
if (!nsContentUtils::ShouldEncodeURLHash()) {
|
||||
NS_UnescapeURL(ref); // XXX may result in random non-ASCII bytes!
|
||||
}
|
||||
AppendUTF8toUTF16(ref, _hash);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -514,8 +514,10 @@ URL::GetHash(nsString& aHash, ErrorResult& aRv) const
|
|||
nsAutoCString ref;
|
||||
nsresult rv = mURI->GetRef(ref);
|
||||
if (NS_SUCCEEDED(rv) && !ref.IsEmpty()) {
|
||||
NS_UnescapeURL(ref); // XXX may result in random non-ASCII bytes!
|
||||
aHash.Assign(char16_t('#'));
|
||||
if (!nsContentUtils::ShouldEncodeURLHash()) {
|
||||
NS_UnescapeURL(ref); // XXX may result in random non-ASCII bytes!
|
||||
}
|
||||
AppendUTF8toUTF16(ref, aHash);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -236,6 +236,7 @@ bool nsContentUtils::sFullscreenApiIsContentOnly = false;
|
|||
bool nsContentUtils::sIsPerformanceTimingEnabled = false;
|
||||
bool nsContentUtils::sIsResourceTimingEnabled = false;
|
||||
bool nsContentUtils::sIsExperimentalAutocompleteEnabled = false;
|
||||
bool nsContentUtils::sEncodeURLHash = true;
|
||||
|
||||
uint32_t nsContentUtils::sHandlingInputTimeout = 1000;
|
||||
|
||||
|
@ -513,6 +514,9 @@ nsContentUtils::Init()
|
|||
Preferences::AddBoolVarCache(&sIsExperimentalAutocompleteEnabled,
|
||||
"dom.forms.autocomplete.experimental", false);
|
||||
|
||||
Preferences::AddBoolVarCache(&sEncodeURLHash,
|
||||
"dom.url.encode_hash", true);
|
||||
|
||||
Preferences::AddUintVarCache(&sHandlingInputTimeout,
|
||||
"dom.event.handling-user-input-time-limit",
|
||||
1000);
|
||||
|
|
|
@ -1853,6 +1853,11 @@ public:
|
|||
return sIsResourceTimingEnabled;
|
||||
}
|
||||
|
||||
static bool ShouldEncodeURLHash()
|
||||
{
|
||||
return sEncodeURLHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the doc tree branch which contains aDoc contains any
|
||||
* plugins which we don't control event dispatch for, i.e. do any plugins
|
||||
|
@ -2304,6 +2309,7 @@ private:
|
|||
static bool sIsPerformanceTimingEnabled;
|
||||
static bool sIsResourceTimingEnabled;
|
||||
static bool sIsExperimentalAutocompleteEnabled;
|
||||
static bool sEncodeURLHash;
|
||||
|
||||
static nsHtml5StringParser* sHTMLFragmentParser;
|
||||
static nsIParser* sXMLFragmentParser;
|
||||
|
|
|
@ -298,28 +298,36 @@ nsLocation::GetHash(nsAString& aHash)
|
|||
nsAutoString unicodeRef;
|
||||
|
||||
rv = uri->GetRef(ref);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsITextToSubURI> textToSubURI(
|
||||
do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv));
|
||||
|
||||
if (!nsContentUtils::ShouldEncodeURLHash()) {
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsAutoCString charset;
|
||||
uri->GetOriginCharset(charset);
|
||||
nsCOMPtr<nsITextToSubURI> textToSubURI(
|
||||
do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv));
|
||||
|
||||
rv = textToSubURI->UnEscapeURIForUI(charset, ref, unicodeRef);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsAutoCString charset;
|
||||
uri->GetOriginCharset(charset);
|
||||
|
||||
rv = textToSubURI->UnEscapeURIForUI(charset, ref, unicodeRef);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
// Oh, well. No intl here!
|
||||
NS_UnescapeURL(ref);
|
||||
CopyASCIItoUTF16(ref, unicodeRef);
|
||||
rv = NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
// Oh, well. No intl here!
|
||||
NS_UnescapeURL(ref);
|
||||
CopyASCIItoUTF16(ref, unicodeRef);
|
||||
rv = NS_OK;
|
||||
if (NS_SUCCEEDED(rv) && !unicodeRef.IsEmpty()) {
|
||||
aHash.Assign(char16_t('#'));
|
||||
aHash.Append(unicodeRef);
|
||||
}
|
||||
} else { // URL Hash should be encoded
|
||||
if (NS_SUCCEEDED(rv) && !ref.IsEmpty()) {
|
||||
aHash.Assign(char16_t('#'));
|
||||
AppendASCIItoUTF16(ref, aHash);
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv) && !unicodeRef.IsEmpty()) {
|
||||
aHash.Assign(char16_t('#'));
|
||||
aHash.Append(unicodeRef);
|
||||
}
|
||||
|
||||
if (aHash == mCachedHash) {
|
||||
|
|
|
@ -161,6 +161,9 @@ pref("dom.webcrypto.enabled", true);
|
|||
// Whether the UndoManager API is enabled
|
||||
pref("dom.undo_manager.enabled", false);
|
||||
|
||||
// Whether URL,nsLocation,Link::GetHash should be percent encoded.
|
||||
pref("dom.url.encode_hash", true);
|
||||
|
||||
// Whether to run add-on code in different compartments from browser code. This
|
||||
// causes a separate compartment for each (addon, global) combination, which may
|
||||
// significantly increase the number of compartments in the system.
|
||||
|
|
Загрузка…
Ссылка в новой задаче