mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1883033 - Fix Scheme ws/wss/ssh url query-encoding wpt failures r=necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D225007
This commit is contained in:
parent
c49e6ea04e
commit
80d65c74e8
@ -1864,6 +1864,14 @@ nsresult NS_NewURI(nsIURI** aURI, const nsACString& aSpec,
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// If encoding is not UTF-8 and url is not special or url’s scheme is "ws" or
|
||||
// "wss" then set encoding to UTF-8.
|
||||
if (aCharset && !scheme.IsEmpty() &&
|
||||
(scheme.EqualsLiteral("ws") || scheme.EqualsLiteral("wss") ||
|
||||
!SchemeIsSpecial(scheme))) {
|
||||
aCharset = "UTF-8";
|
||||
}
|
||||
|
||||
if (scheme.EqualsLiteral("http") || scheme.EqualsLiteral("ws")) {
|
||||
return NewStandardURI(aSpec, aCharset, aBaseURI, NS_HTTP_DEFAULT_PORT,
|
||||
aURI);
|
||||
|
@ -99,6 +99,8 @@ support-files = [
|
||||
["test_accept_header.html"]
|
||||
support-files = ["test_accept_header.sjs"]
|
||||
|
||||
["test_anchor_query_encoding.html"]
|
||||
|
||||
["test_arraybufferinputstream.html"]
|
||||
|
||||
["test_arraybufferinputstream_large.html"]
|
||||
|
44
netwerk/test/mochitests/test_anchor_query_encoding.html
Normal file
44
netwerk/test/mochitests/test_anchor_query_encoding.html
Normal file
@ -0,0 +1,44 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="windows-1251">
|
||||
<title>Testing <a>.href (windows-1251)</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript">
|
||||
|
||||
const UTF_8 = '%C3%A5';
|
||||
const WINDOWS_1251 = '%26%23229%3B';
|
||||
|
||||
function test_scheme(url, expected) {
|
||||
var a = document.createElement('a');
|
||||
a.setAttribute('href', url);
|
||||
ok(a.href.includes(expected), `Expected: ${expected}, Actual: ${a.href}`);
|
||||
}
|
||||
|
||||
add_task(async function test_bug1883033() {
|
||||
// Scheme http (getting <a>.href)
|
||||
// eslint-disable-next-line @microsoft/sdl/no-insecure-url
|
||||
test_scheme("http://example.invalid/?x=\u00E5", WINDOWS_1251);
|
||||
|
||||
// Scheme https (getting <a>.href)
|
||||
test_scheme("https://example.invalid/?x=\u00E5", WINDOWS_1251);
|
||||
|
||||
// If encoding is not UTF-8 and url’s scheme is "ws" or "wss",
|
||||
// then encoding should be set to UTF-8.
|
||||
// Scheme ws (getting <a>.href)
|
||||
test_scheme("ws://example.invalid/?x=\u00E5", UTF_8);
|
||||
|
||||
// Scheme wss (getting <a>.href)
|
||||
test_scheme("wss://example.invalid/?x=\u00E5", UTF_8);
|
||||
|
||||
// If encoding is not UTF-8 and url is not special,
|
||||
// then encoding should be UTF-8.
|
||||
// Scheme ssh (getting <a>.href)
|
||||
test_scheme("ssh://foo/?x=\u00E5", UTF_8);
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@ -280,12 +280,6 @@
|
||||
|
||||
|
||||
[windows-1251.html?include=scheme]
|
||||
[Scheme ws (getting <a>.href)]
|
||||
expected: FAIL
|
||||
|
||||
[Scheme wss (getting <a>.href)]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[windows-1251.html?include=appcache]
|
||||
[Parsing cache manifest (CACHE)]
|
||||
|
@ -82,12 +82,6 @@
|
||||
[windows-1252.html?include=submit]
|
||||
|
||||
[windows-1252.html?include=scheme]
|
||||
[Scheme ws (getting <a>.href)]
|
||||
expected: FAIL
|
||||
|
||||
[Scheme wss (getting <a>.href)]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[windows-1252.html?include=eventsource]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user