From f024462b35339423cc9b32b67104add08e668582 Mon Sep 17 00:00:00 2001 From: Simone Margaritelli Date: Sat, 4 Nov 2023 17:46:38 +0100 Subject: [PATCH] fix: fixed parse_target by stripping elements that caused problems --- src/session/mod.rs | 4 +--- src/utils/target/single.rs | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/session/mod.rs b/src/session/mod.rs index a15ee70..642add8 100644 --- a/src/session/mod.rs +++ b/src/session/mod.rs @@ -108,9 +108,7 @@ impl Session { // perform pre-emptive target validation for target in &targets { - if let Err(e) = parse_target(target, 0) { - return Err(e); - } + parse_target(target, 0)?; } let runtime = Runtime::new(options.concurrency); diff --git a/src/utils/target/single.rs b/src/utils/target/single.rs index f12760c..56cbef4 100644 --- a/src/utils/target/single.rs +++ b/src/utils/target/single.rs @@ -8,6 +8,20 @@ pub(crate) fn parse_target(target: &str, default_port: u16) -> Result<(String, u )); } + // remove :// if present + let target = if target.contains("://") { + target.split_once("://").unwrap().1 + } else { + target + }; + + // remove / if present + let target = if target.contains('/') { + target.split_once('/').unwrap().0 + } else { + target + }; + let num_colons = target.matches(':').count(); let (address, port) = if num_colons <= 1 { // domain or ipv4