Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement checks on Location setters #23670

Closed
wants to merge 6 commits into from
Next

only allow http/https protocols

  • Loading branch information
braddunbar committed Jun 30, 2019
commit 98452495dd63a121e8e6d14386a26c0b628a52e8
@@ -217,7 +217,11 @@ impl LocationMethods for Location {
// https://html.spec.whatwg.org/multipage/#dom-location-protocol
fn SetProtocol(&self, value: USVString) -> ErrorResult {
self.check_same_origin_domain()?;
self.set_url_component(value, UrlHelper::SetProtocol);
// If copyURL's scheme is not an HTTP(S) scheme, then terminate these steps.
let scheme = value.split(':').next().unwrap();
if scheme.eq_ignore_ascii_case("http") || scheme.eq_ignore_ascii_case("https") {

This comment has been minimized.

Copy link
@gterzian

gterzian Jul 1, 2019

Member

The spec contains this note:

Because the URL parser ignores multiple consecutive colons, providing a value of "https:" (or even "https::::") is the same as providing a value of "https".

Does this allow for multiple consecutive colons?

If this is currently not tested in the existing tests, you could also consider adding such a testcase.

This comment has been minimized.

Copy link
@braddunbar

braddunbar Jul 1, 2019

Author

Ok, I'll write some tests!

self.set_url_component(value, UrlHelper::SetProtocol);
}
Ok(())
}

@@ -17,19 +17,3 @@

[Set data URL frame location.protocol to http+x]
expected: FAIL

[Set HTTP URL frame location.protocol to gopher]
expected: FAIL

[Set HTTP URL frame location.protocol to http+x]
expected: FAIL

[Set HTTP URL frame location.protocol to ftp]
expected: FAIL

[Set HTTP URL frame location.protocol to data]
expected: FAIL

[Set HTTP URL frame location.protocol to x]
expected: FAIL

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.