Permalink
Browse files

WinSW should handle whitespace in the argument correctly

Cherry picked 83380bd
  • Loading branch information...
1 parent a5da052 commit 088cfd232a518d5612b2df713ea953d6e098d553 @kohsuke committed Oct 27, 2011
Showing with 17 additions and 2 deletions.
  1. +17 −2 ServiceDescriptor.cs
View
@@ -157,7 +157,7 @@ public string Stoparguments
/// <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 @@ private string AppendTags(string 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);

0 comments on commit 088cfd2

Please sign in to comment.