Browse Source

WinSW should handle whitespace in the argument correctly

Cherry picked 83380bdd9b801d82022ca58d9637300494f1ee8b
Kohsuke Kawaguchi 14 years ago
parent
commit
088cfd232a
1 changed files with 17 additions and 2 deletions
  1. 17 2
      ServiceDescriptor.cs

+ 17 - 2
ServiceDescriptor.cs

@@ -157,7 +157,7 @@ namespace winsw
 
         /// <summary>
         /// 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 quotatoin.
         /// </summary>
         private string AppendTags(string tagName)
         {
@@ -173,7 +173,22 @@ 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);