WinSW should handle whitespace in the argument correctly

Cherry picked 83380bdd9b
pull/4/head
Kohsuke Kawaguchi 2011-10-27 09:18:02 -07:00
parent a5da052192
commit 088cfd232a
1 changed files with 17 additions and 2 deletions

View File

@ -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);