From 83380bdd9b801d82022ca58d9637300494f1ee8b Mon Sep 17 00:00:00 2001 From: kohsuke Date: Tue, 9 Feb 2010 19:15:19 +0000 Subject: [PATCH] WinSW should handle whitespace in the argument correctly git-svn-id: https://svn.kenai.com/svn/winsw~subversion/trunk@43 c8b2a3fe-9b5b-6a51-a37e-dc31b0e308fa --- Main.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Main.cs b/Main.cs index 9959842..40e073e 100644 --- a/Main.cs +++ b/Main.cs @@ -180,7 +180,7 @@ namespace winsw /// /// Combines the contents of all the elements of the given name, - /// or return null if no element exists. + /// or return null if no element exists. Handles whitespace quotation. /// private string AppendTags(string tagName) { @@ -196,7 +196,21 @@ namespace winsw foreach (XmlNode argument in dom.SelectNodes("//" + tagName)) { - arguments += " " + argument.InnerText; + string token = argument.InnerText; + if (token.StartsWith("\"") && token.EndsWith("\"")) + { + // for backward compatibility, if the argument is already quoted, leave it as is. + // in earlier versions we didn't handle quotation, so the user might have worked + // around it by themselves + } + else + { + if (token.Contains(" ")) + { + token = '"' + token + '"'; + } + } + arguments += " " + token; } return Environment.ExpandEnvironmentVariables(arguments);