Skip to content
This repository was archived by the owner on Dec 18, 2017. It is now read-only.

Commit

Permalink
Fix #876, Correct handling of quotation marks in commands
Browse files Browse the repository at this point in the history
- remove extra quotes around `cmd /c` arguments
 - prevented && and similar special cases
- don't strip quotes surrounding command-line arguments
 - prevented command paths and arguments containing spaces
- `CommandGrammar` may need additional generalizations
 - e.g. unquoted term can't contain more than one escape sequence
 - but it's probably good enough for now
  • Loading branch information
dougbu committed Dec 1, 2014
1 parent 673fbbe commit c9e7ef8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public CommandGrammar(Func<string, string> variable)

var unquotedTerm = Rep1(unquotedPiece.Or(specialPiece)).Str();

var quotedTerm = Ch('\"').And(Rep(quotedPiece.Or(specialPiece)).Str()).And(Ch('\"')).Left().Down();
var quotedTerm = Ch('\"').And(Rep(quotedPiece.Or(specialPiece)).Str()).And(Ch('\"'))
.Left().Down()
.Build(str => "\"" + str + "\"");

var whitespace = Rep(Ch(' '));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ public void Execute(
if (!string.IsNullOrEmpty(comSpec))
{
scriptArguments =
new[] { comSpec, "/C", "\"" }
new[] { comSpec, "/C" }
.Concat(scriptArguments)
.Concat(new[] { "\"" })
.ToArray();
}
}
Expand Down

0 comments on commit c9e7ef8

Please sign in to comment.