From d108f3f9b8039e660c968114eb052fee3d707e66 Mon Sep 17 00:00:00 2001 From: Yatao Li Date: Tue, 13 Aug 2019 17:17:50 +0800 Subject: [PATCH] fix argument escaping --- common.fs | 1 + neovim/neovim.process.fs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/common.fs b/common.fs index 29d0729..a7511ef 100644 --- a/common.fs +++ b/common.fs @@ -92,6 +92,7 @@ let (|ForceBool|_|) (x:obj) = type hashmap<'a, 'b> = System.Collections.Generic.Dictionary<'a, 'b> let hashmap (xs: seq<'a*'b>) = new hashmap<'a,'b>(xs |> Seq.map (fun (a,b) -> System.Collections.Generic.KeyValuePair(a,b))) +let escapeArgs: string seq -> string seq = Seq.map (fun (x: string) -> if x.Contains(' ') then sprintf "\"%s\"" (x.Replace("\"", "\\\"")) else x) let join (xs: string seq) = System.String.Join(" ", xs) let inline (>>=) (x: 'a option) (f: 'a -> 'b option) = diff --git a/neovim/neovim.process.fs b/neovim/neovim.process.fs index 630a352..017d775 100644 --- a/neovim/neovim.process.fs +++ b/neovim/neovim.process.fs @@ -51,7 +51,7 @@ type Nvim() = match serveropts with | StartNew -> let args = "--embed" :: args - let psi = ProcessStartInfo(prog, join(preargs @ args)) + let psi = ProcessStartInfo(prog, (join << escapeArgs) (preargs @ args)) psi.CreateNoWindow <- true psi.ErrorDialog <- false psi.RedirectStandardError <- true