diff options
author | Jacob Gee-Clarke <jacob.clarke2@gmail.com> | 2020-07-02 15:16:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-02 10:16:41 -0400 |
commit | 74c260517a40d9644960b01415824e1c6c646fde (patch) | |
tree | 6553c2372c9cabc0393b5382c91afc19dab52c94 | |
parent | 8a14eafaff3511fe3b5c6df9d958b565f80d93de (diff) |
fix: net permissions didn't account for default ports (#6606)
-rw-r--r-- | cli/permissions.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/cli/permissions.rs b/cli/permissions.rs index bd9b8d950..2e378b497 100644 --- a/cli/permissions.rs +++ b/cli/permissions.rs @@ -291,9 +291,10 @@ impl Permissions { .to_owned(), )); } - Ok( - self.get_state_net(&format!("{}", parsed.host().unwrap()), parsed.port()), - ) + Ok(self.get_state_net( + &format!("{}", parsed.host().unwrap()), + parsed.port_or_known_default(), + )) } pub fn check_net(&self, hostname: &str, port: u16) -> Result<(), OpError> { @@ -308,7 +309,7 @@ impl Permissions { .host_str() .ok_or_else(|| OpError::uri_error("missing host".to_owned()))?; self - .get_state_net(host, url.port()) + .get_state_net(host, url.port_or_known_default()) .check(&format!("network access to \"{}\"", url), "--allow-net") } @@ -629,7 +630,8 @@ mod tests { "deno.land", "github.com:3000", "127.0.0.1", - "172.16.0.2:8000" + "172.16.0.2:8000", + "www.github.com:443" ], ..Default::default() }); @@ -692,6 +694,8 @@ mod tests { ("https://172.16.0.2:6000", false), ("tcp://172.16.0.1:8000", false), ("https://172.16.0.1:8000", false), + // Testing issue #6531 (Network permissions check doesn't account for well-known default ports) so we dont regress + ("https://www.github.com:443/robots.txt", true), ]; for (url_str, is_ok) in url_tests.iter() { |