From 74c260517a40d9644960b01415824e1c6c646fde Mon Sep 17 00:00:00 2001 From: Jacob Gee-Clarke Date: Thu, 2 Jul 2020 15:16:41 +0100 Subject: fix: net permissions didn't account for default ports (#6606) --- cli/permissions.rs | 14 +++++++++----- 1 file 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() { -- cgit v1.2.3