forked from mirrors/gecko-dev
Bug 1873944 - Also parse about and data urls with DefaultURI if starting with '/'. r=necko-reviewers,valentin,rpl
Differential Revision: https://phabricator.services.mozilla.com/D205062
This commit is contained in:
parent
63baa88260
commit
70cc93ae5b
8 changed files with 18 additions and 83 deletions
|
|
@ -21,6 +21,7 @@
|
|||
#include "nsIChannel.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsIClassInfoImpl.h"
|
||||
#include "DefaultURI.h"
|
||||
|
||||
#include "mozilla/ipc/URIUtils.h"
|
||||
|
||||
|
|
@ -136,6 +137,16 @@ nsresult nsAboutProtocolHandler::CreateNewURI(const nsACString& aSpec,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// use DefaultURI to check for validity when we have possible hostnames
|
||||
// since nsSimpleURI doesn't know about hostnames
|
||||
auto pos = aSpec.Find("about:/");
|
||||
if (pos != kNotFound) {
|
||||
rv = NS_MutateURI(new mozilla::net::DefaultURI::Mutator())
|
||||
.SetSpec(aSpec)
|
||||
.Finalize(url);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
url.swap(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,16 +68,12 @@ nsDataHandler::GetScheme(nsACString& result) {
|
|||
|
||||
// use DefaultURI to check for validity when we have possible hostnames
|
||||
// since nsSimpleURI doesn't know about hostnames
|
||||
auto pos = aSpec.Find("data:");
|
||||
auto pos = aSpec.Find("data:/");
|
||||
if (pos != kNotFound) {
|
||||
nsDependentCSubstring rest(aSpec, pos + sizeof("data:") - 1, -1);
|
||||
if (StringBeginsWith(rest, "//"_ns)) {
|
||||
nsCOMPtr<nsIURI> uriWithHost;
|
||||
rv = NS_MutateURI(new mozilla::net::DefaultURI::Mutator())
|
||||
.SetSpec(aSpec)
|
||||
.Finalize(uriWithHost);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
rv = NS_MutateURI(new mozilla::net::DefaultURI::Mutator())
|
||||
.SetSpec(aSpec)
|
||||
.Finalize(uri);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
uri.forget(result);
|
||||
|
|
|
|||
|
|
@ -971,9 +971,6 @@
|
|||
[Parsing: <http://example.com/foo/%2e> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <about:/../> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <http://!"$&'()*+,-.;=_`{}~/> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
|
|
@ -983,17 +980,5 @@
|
|||
[Parsing: <wss://host/ !"$%&'()*+,-./:;<=>@[\\\]^_`{|}~> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <data:/../> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <data://example.com:8080/pathname?search#hash> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <data:///test> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <data://test/a/../b> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[a-element-xhtml.xhtml?include=mailto]
|
||||
|
|
|
|||
|
|
@ -1000,9 +1000,6 @@
|
|||
[Parsing: <http://example.com/foo/%2e> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <about:/../> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <http://!"$&'()*+,-.;=_`{}~/> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
|
|
@ -1012,17 +1009,5 @@
|
|||
[Parsing: <wss://host/ !"$%&'()*+,-./:;<=>@[\\\]^_`{|}~> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <data:/../> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <data://example.com:8080/pathname?search#hash> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <data:///test> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <data://test/a/../b> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[a-element.html?include=mailto]
|
||||
|
|
|
|||
|
|
@ -1200,9 +1200,6 @@
|
|||
[Parsing: <http://example.com/foo/%2e> without base]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <about:/../> without base]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <http://!"$&'()*+,-.;=_`{}~/> without base]
|
||||
expected: FAIL
|
||||
|
||||
|
|
@ -1212,18 +1209,6 @@
|
|||
[Parsing: <wss://host/ !"$%&'()*+,-./:;<=>@[\\\]^_`{|}~> without base]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <data:/../> without base]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <data://example.com:8080/pathname?search#hash> without base]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <data:///test> without base]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <data://test/a/../b> without base]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[url-constructor.any.html?include=file]
|
||||
[Parsing: <file:c:\\foo\\bar.html> against <file:///tmp/mock/path>]
|
||||
|
|
@ -1545,9 +1530,6 @@
|
|||
[Parsing: <http://example.com/foo/%2e> without base]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <about:/../> without base]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <http://!"$&'()*+,-.;=_`{}~/> without base]
|
||||
expected: FAIL
|
||||
|
||||
|
|
@ -1557,18 +1539,6 @@
|
|||
[Parsing: <wss://host/ !"$%&'()*+,-./:;<=>@[\\\]^_`{|}~> without base]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <data:/../> without base]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <data://example.com:8080/pathname?search#hash> without base]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <data:///test> without base]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <data://test/a/../b> without base]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[url-constructor.any.html?include=javascript]
|
||||
[Parsing: <javascript:/../> without base]
|
||||
|
|
|
|||
|
|
@ -55,12 +55,6 @@
|
|||
[<area>: Setting <non-spec:/>.pathname = '//p']
|
||||
expected: FAIL
|
||||
|
||||
[<a>: Setting <data:/nospace>.pathname = 'space ' Non-special URLs with non-opaque paths percent-encode U+0020]
|
||||
expected: FAIL
|
||||
|
||||
[<area>: Setting <data:/nospace>.pathname = 'space ' Non-special URLs with non-opaque paths percent-encode U+0020]
|
||||
expected: FAIL
|
||||
|
||||
[<a>: Setting <data:space ?query#fragment>.search = '' Do not drop trailing spaces from non-trailing opaque paths]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
|||
|
|
@ -444,9 +444,6 @@
|
|||
[URL: Setting <non-spec:/.//>.pathname = 'p' Drop /. from path]
|
||||
expected: FAIL
|
||||
|
||||
[URL: Setting <data:/nospace>.pathname = 'space ' Non-special URLs with non-opaque paths percent-encode U+0020]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[url-setters.any.html?include=file]
|
||||
[URL: Setting <file://hi/path>.protocol = 's']
|
||||
|
|
@ -507,9 +504,6 @@
|
|||
[URL: Setting <non-spec:/.//>.pathname = 'p' Drop /. from path]
|
||||
expected: FAIL
|
||||
|
||||
[URL: Setting <data:/nospace>.pathname = 'space ' Non-special URLs with non-opaque paths percent-encode U+0020]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[url-setters.any.worker.html?include=file]
|
||||
[URL: Setting <file://hi/path>.protocol = 's']
|
||||
|
|
|
|||
|
|
@ -226,14 +226,14 @@ add_task(async function test_match_url_filters() {
|
|||
// TODO: should we explicitly cover hostContains, hostPrefix, hostSuffix for
|
||||
// these sub-cases?
|
||||
{ shouldFail, filters: [{ hostEquals: "blank" }], url: "about:blank" },
|
||||
{ shouldFail, filters: [{ hostEquals: "blank" }], url: "about://blank" },
|
||||
{ shouldPass, filters: [{ hostEquals: "blank" }], url: "about://blank" },
|
||||
{
|
||||
shouldFail,
|
||||
filters: [{ hostEquals: "testDataURL" }],
|
||||
url: "data:,testDataURL",
|
||||
},
|
||||
{ shouldPass, filters: [{ hostEquals: "" }], url: "about:blank" },
|
||||
{ shouldPass, filters: [{ hostEquals: "" }], url: "about://blank" },
|
||||
{ shouldFail, filters: [{ hostEquals: "" }], url: "about://blank" },
|
||||
{ shouldPass, filters: [{ hostEquals: "" }], url: "data:,testDataURL" },
|
||||
|
||||
// Path filters (pathEquals, pathContains, pathPrefix, pathSuffix).
|
||||
|
|
|
|||
Loading…
Reference in a new issue