mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 16:25:38 +00:00
Bug 1271553 - Add known dweb protocols and ext+ to the standard list r=kershaw
Fix for the Bug 1536744 removed abiliti for nsIProtocolHandler to parse URLs of the custom protocols & broke libdweb. In order to fix followup change for Bug 1559356 introduced a whitelist for dweb: and dat: protocols to parse those as nsIStandardURLs. This change extends whitelist with ipfs: ipns: ssb: schemes and ext+ prefix scheme. This would allow Bug 1271553 to progress until better more general solution can be implemnted. Differential Revision: https://phabricator.services.mozilla.com/D39463 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
954851b187
commit
e83a6e8364
@ -1848,7 +1848,15 @@ nsresult NS_NewURI(nsIURI** aURI, const nsACString& aSpec,
|
||||
.Finalize(aURI);
|
||||
}
|
||||
|
||||
if (scheme.EqualsLiteral("dweb") || scheme.EqualsLiteral("dat")) {
|
||||
// web-extensions can add custom protocol implementations with standard URLs
|
||||
// that have notion of hostname, authority and relative URLs. Below we
|
||||
// manually check agains set of known protocols schemes and `ext+` prefix
|
||||
// (used by web-extensions) until more general solution is in place
|
||||
// (See Bug 1569733)
|
||||
if (scheme.EqualsLiteral("dweb") || scheme.EqualsLiteral("dat") ||
|
||||
scheme.EqualsLiteral("ipfs") || scheme.EqualsLiteral("ipns") ||
|
||||
scheme.EqualsLiteral("ssb") || scheme.EqualsLiteral("wtp") ||
|
||||
StringBeginsWith(scheme, NS_LITERAL_CSTRING("ext+"))) {
|
||||
return NewStandardURI(aSpec, aCharset, aBaseURI, -1, aURI);
|
||||
}
|
||||
|
||||
|
@ -923,8 +923,11 @@ function check_resolve() {
|
||||
}
|
||||
|
||||
function test_extra_protocols() {
|
||||
// dweb://
|
||||
let url = gIoService.newURI("dweb://example.com/test");
|
||||
Assert.equal(url.host, "example.com");
|
||||
|
||||
// dat://
|
||||
url = gIoService.newURI(
|
||||
"dat://41f8a987cfeba80a037e51cc8357d513b62514de36f2f9b3d3eeec7a8fb3b5a5/"
|
||||
);
|
||||
@ -934,6 +937,43 @@ function test_extra_protocols() {
|
||||
);
|
||||
url = gIoService.newURI("dat://example.com/test");
|
||||
Assert.equal(url.host, "example.com");
|
||||
|
||||
// ipfs://
|
||||
url = gIoService.newURI(
|
||||
"ipfs://bafybeiccfclkdtucu6y4yc5cpr6y3yuinr67svmii46v5cfcrkp47ihehy/frontend/license.txt"
|
||||
);
|
||||
Assert.equal(url.scheme, "ipfs");
|
||||
Assert.equal(
|
||||
url.host,
|
||||
"bafybeiccfclkdtucu6y4yc5cpr6y3yuinr67svmii46v5cfcrkp47ihehy"
|
||||
);
|
||||
Assert.equal(url.filePath, "/frontend/license.txt");
|
||||
|
||||
// ipns://
|
||||
url = gIoService.newURI("ipns://peerdium.gozala.io/index.html");
|
||||
Assert.equal(url.scheme, "ipns");
|
||||
Assert.equal(url.host, "peerdium.gozala.io");
|
||||
Assert.equal(url.filePath, "/index.html");
|
||||
|
||||
// ssb://
|
||||
url = gIoService.newURI("ssb://scuttlebutt.nz/index.html");
|
||||
Assert.equal(url.scheme, "ssb");
|
||||
Assert.equal(url.host, "scuttlebutt.nz");
|
||||
Assert.equal(url.filePath, "/index.html");
|
||||
|
||||
// wtp://
|
||||
url = gIoService.newURI(
|
||||
"wtp://951ead31d09e4049fc1f21f137e233dd0589fcbd/blog/vim-tips/"
|
||||
);
|
||||
Assert.equal(url.scheme, "wtp");
|
||||
Assert.equal(url.host, "951ead31d09e4049fc1f21f137e233dd0589fcbd");
|
||||
Assert.equal(url.filePath, "/blog/vim-tips/");
|
||||
|
||||
// ext+*://
|
||||
url = gIoService.newURI("ext+foo://whatever/dir/file");
|
||||
Assert.equal(url.scheme, "ext+foo");
|
||||
Assert.equal(url.host, "whatever");
|
||||
Assert.equal(url.filePath, "/dir/file");
|
||||
}
|
||||
|
||||
// TEST MAIN FUNCTION
|
||||
|
Loading…
Reference in New Issue
Block a user