diff --git a/CHANGELOG.md b/CHANGELOG.md index d17e37647e..81bb2128e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ Changelog Unreleased ---------- +- Fix passing escaped double quoted spaces to native executables + v6.0.0-alpha.9 - 2016-08-15 --------------------------- diff --git a/src/System.Management.Automation/engine/NativeCommandParameterBinder.cs b/src/System.Management.Automation/engine/NativeCommandParameterBinder.cs index 14083cb80a..62e282ca37 100644 --- a/src/System.Management.Automation/engine/NativeCommandParameterBinder.cs +++ b/src/System.Management.Automation/engine/NativeCommandParameterBinder.cs @@ -194,11 +194,11 @@ namespace System.Management.Automation // just the normal double quotes, no other special quotes. Also note that mismatched // quotes are supported. - bool needQuotes = false; + bool needQuotes = false, followingBackslash = false; int quoteCount = 0; for (int i = 0; i < arg.Length; i++) { - if (arg[i] == '"') + if (arg[i] == '"' && !followingBackslash) { quoteCount += 1; } @@ -206,6 +206,8 @@ namespace System.Management.Automation { needQuotes = true; } + + followingBackslash = arg[i] == '\\'; } if (needQuotes)