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

Add comments linking to the steps of the specs in the checks on Location setters #25714

Closed
wants to merge 9 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();

This comment has been minimized.

Copy link
@paulrouget

paulrouget Feb 10, 2020

Contributor

Isn’t it dangerous to have unwrap() here?

This comment has been minimized.

Copy link
@gterzian

gterzian Feb 10, 2020

Member

Yes you're right, actually per Step 5 of the protocol setter spec, I think we should return a Error::Syntax here instead of unwrap, see https://html.spec.whatwg.org/multipage/history.html#dom-location-protocol

This would be using use crate::dom::bindings::error::Error;

This comment has been minimized.

Copy link
@UxioAndrade

UxioAndrade Feb 10, 2020

Author

Would my latest commit fix that?

if scheme.eq_ignore_ascii_case("http") || scheme.eq_ignore_ascii_case("https") {
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.