Bug 1559356 - Make sure dweb URLs have a proper host r=kershaw

We want dweb URLs to continue working as before bug 1536744 landed.
So we make sure to instantiate it as an nsStandardURL.
This is not a good long-term solution, as we don't want to hardcode
all the various schemes that we want to behave properly.
The fix would be to add a new spec-compliant nsIURI implementation,
based on RustURL and use it for all unknown schemes.

See bug 1561860 for a more complete solution.

Differential Revision: https://phabricator.services.mozilla.com/D36168

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Valentin Gosu 2019-06-28 13:12:49 +00:00
Родитель 18d79cb494
Коммит 7f899f94dd
2 изменённых файлов: 14 добавлений и 0 удалений

Просмотреть файл

@ -1861,6 +1861,10 @@ nsresult NS_NewURI(nsIURI** aURI, const nsACString& aSpec,
.Finalize(aURI);
}
if (scheme.EqualsLiteral("dweb") || scheme.EqualsLiteral("dat")) {
return NewStandardURI(aSpec, aCharset, aBaseURI, -1, aURI);
}
#if defined(MOZ_THUNDERBIRD) || defined(MOZ_SUITE)
rv = NS_NewMailnewsURI(aURI, aSpec, aCharset, aBaseURI, aIOService);
if (rv != NS_ERROR_UNKNOWN_PROTOCOL) {

Просмотреть файл

@ -639,6 +639,15 @@ function check_resolve() {
Assert.equal(uri.spec, "tel::+371 27028456");
}
function test_extra_protocols() {
let url = gIoService.newURI("dweb://example.com/test");
Assert.equal(url.host, "example.com");
url = gIoService.newURI("dat://41f8a987cfeba80a037e51cc8357d513b62514de36f2f9b3d3eeec7a8fb3b5a5/");
Assert.equal(url.host, "41f8a987cfeba80a037e51cc8357d513b62514de36f2f9b3d3eeec7a8fb3b5a5");
url = gIoService.newURI("dat://example.com/test");
Assert.equal(url.host, "example.com");
}
// TEST MAIN FUNCTION
// ------------------
function run_test()
@ -648,6 +657,7 @@ function run_test()
check_schemeIsNull();
check_mozextension_query();
check_resolve();
test_extra_protocols();
// UTF-8 check - From bug 622981
// ASCII