mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
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:
parent
731489bb3d
commit
34162c2171
@ -1550,8 +1550,17 @@ XMLHttpRequestMainThread::Open(const nsACString& aMethod,
|
||||
} else if (responsibleDocument) {
|
||||
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;
|
||||
rv = NS_NewURI(getter_AddRefs(parsedURL), aUrl, nullptr, baseURI);
|
||||
rv = NS_NewURI(getter_AddRefs(parsedURL), aUrl, originCharset, baseURI);
|
||||
if (NS_FAILED(rv)) {
|
||||
if (rv == NS_ERROR_MALFORMED_URI) {
|
||||
return NS_ERROR_DOM_MALFORMED_URI;
|
||||
|
@ -14,14 +14,14 @@
|
||||
var client = new XMLHttpRequest()
|
||||
client.open("GET", "resources/content.py?\u00DF", false) // This is the German "eszett" character
|
||||
client.send()
|
||||
assert_equals(client.getResponseHeader("x-request-query"), "%C3%9F")
|
||||
assert_equals(client.getResponseHeader("x-request-query"), "%DF")
|
||||
}, "percent encode characters");
|
||||
test(function() {
|
||||
var client = new XMLHttpRequest()
|
||||
client.open("GET", "resources/content.py?\uD83D", false)
|
||||
client.send()
|
||||
assert_equals(client.getResponseHeader("x-request-query"), "%EF%BF%BD")
|
||||
}, "lone surrogate should return U+FFFD");
|
||||
assert_equals(client.getResponseHeader("x-request-query"), "&%2365533;")
|
||||
}, "lone surrogate");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user