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

port: abort if url cannot have username/password/port

  • Loading branch information
braddunbar committed Jun 30, 2019
commit 97e967ce0ef09365d06b351960e1f97354ff99cb
@@ -210,7 +210,11 @@ impl LocationMethods for Location {
// https://html.spec.whatwg.org/multipage/#dom-location-port
fn SetPort(&self, value: USVString) -> ErrorResult {
self.check_same_origin_domain()?;
self.set_url_component(value, UrlHelper::SetPort);
let url = self.get_url();
// If copyURL cannot have a username/password/port, then return.

This comment has been minimized.

Copy link
@gterzian

This comment has been minimized.

Copy link
@braddunbar
if url.has_host() && !url.cannot_be_a_base() && url.scheme() != "file" {
self.set_url_component(value, UrlHelper::SetPort);
}
Ok(())
}

@@ -93,6 +93,10 @@ impl ServoUrl {
self.0.scheme()
}

pub fn has_host(&self) -> bool {
self.0.has_host()
}

pub fn is_secure_scheme(&self) -> bool {
let scheme = self.scheme();
scheme == "https" || scheme == "wss"
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.