зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1405696
- pass the document encoding to NS_NewURI for XMLHttpRequest; r=bkelly
MozReview-Commit-ID: IZkWHGZacO0 --HG-- extra : rebase_source : 4cffffd6ce76f49f8515a04cd4f7523e5ceabb1f
This commit is contained in:
Родитель
731489bb3d
Коммит
34162c2171
|
@ -1550,8 +1550,17 @@ XMLHttpRequestMainThread::Open(const nsACString& aMethod,
|
||||||
} else if (responsibleDocument) {
|
} else if (responsibleDocument) {
|
||||||
baseURI = responsibleDocument->GetBaseURI();
|
baseURI = responsibleDocument->GetBaseURI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use the responsible document's encoding for the URL if we have one,
|
||||||
|
// except for dedicated workers. Use UTF-8 otherwise.
|
||||||
|
NotNull<const Encoding*> originCharset = UTF_8_ENCODING;
|
||||||
|
if (responsibleDocument &&
|
||||||
|
responsibleDocument->NodePrincipal() == mPrincipal) {
|
||||||
|
originCharset = responsibleDocument->GetDocumentCharacterSet();
|
||||||
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> parsedURL;
|
nsCOMPtr<nsIURI> parsedURL;
|
||||||
rv = NS_NewURI(getter_AddRefs(parsedURL), aUrl, nullptr, baseURI);
|
rv = NS_NewURI(getter_AddRefs(parsedURL), aUrl, originCharset, baseURI);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
if (rv == NS_ERROR_MALFORMED_URI) {
|
if (rv == NS_ERROR_MALFORMED_URI) {
|
||||||
return NS_ERROR_DOM_MALFORMED_URI;
|
return NS_ERROR_DOM_MALFORMED_URI;
|
||||||
|
|
|
@ -14,14 +14,14 @@
|
||||||
var client = new XMLHttpRequest()
|
var client = new XMLHttpRequest()
|
||||||
client.open("GET", "resources/content.py?\u00DF", false) // This is the German "eszett" character
|
client.open("GET", "resources/content.py?\u00DF", false) // This is the German "eszett" character
|
||||||
client.send()
|
client.send()
|
||||||
assert_equals(client.getResponseHeader("x-request-query"), "%C3%9F")
|
assert_equals(client.getResponseHeader("x-request-query"), "%DF")
|
||||||
}, "percent encode characters");
|
}, "percent encode characters");
|
||||||
test(function() {
|
test(function() {
|
||||||
var client = new XMLHttpRequest()
|
var client = new XMLHttpRequest()
|
||||||
client.open("GET", "resources/content.py?\uD83D", false)
|
client.open("GET", "resources/content.py?\uD83D", false)
|
||||||
client.send()
|
client.send()
|
||||||
assert_equals(client.getResponseHeader("x-request-query"), "%EF%BF%BD")
|
assert_equals(client.getResponseHeader("x-request-query"), "&%2365533;")
|
||||||
}, "lone surrogate should return U+FFFD");
|
}, "lone surrogate");
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче