Forráskód Böngészése

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
kohsuke 16 éve
szülő
commit
83380bdd9b
1 módosított fájl, 16 hozzáadás és 2 törlés
  1. 16 2
      Main.cs

+ 16 - 2
Main.cs

@@ -180,7 +180,7 @@ namespace winsw
 
 
         /// <summary>
         /// <summary>
         /// Combines the contents of all the elements of the given name,
         /// 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.
         /// </summary>
         /// </summary>
         private string AppendTags(string tagName)
         private string AppendTags(string tagName)
         {
         {
@@ -196,7 +196,21 @@ namespace winsw
 
 
                 foreach (XmlNode argument in dom.SelectNodes("//" + tagName))
                 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);
                 return Environment.ExpandEnvironmentVariables(arguments);