From 3da3e74aa2a4001e84899dd12544b7554e8b95b6 Mon Sep 17 00:00:00 2001 From: Amod Malviya Date: Wed, 16 Aug 2023 21:59:11 +0530 Subject: [PATCH] handle ampersand correctly in WSL env --- src/unix.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/unix.rs b/src/unix.rs index 50162ec..1778661 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -195,9 +195,22 @@ fn try_wsl(options: &BrowserOptions, target: &TargetType) -> Result<()> { match target.0.scheme() { "http" | "https" => { let url: &str = target; - try_browser!(options, "cmd.exe", "/c", "start", url) - .or_else(|_| try_browser!(options, "powershell.exe", "Start", url)) - .or_else(|_| try_browser!(options, "wsl-open", url)) + try_browser!( + options, + "cmd.exe", + "/c", + "start", + url.replace("^", "^^").replace("&", "^&") + ) + .or_else(|_| { + try_browser!( + options, + "powershell.exe", + "Start", + url.replace("&", "\"&\"") + ) + }) + .or_else(|_| try_browser!(options, "wsl-open", url)) } #[cfg(all( target_os = "linux",