[FIXED HUDSON-7657] While testing from command prompt requires escaping of ^&<>|

with a ^ character, this is apparently not needed when cmd.exe /C is invoked from
Hudson.. commented that part of toWindowsCommand() and updated javadoc/unit test.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@36903 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
mindless committed 2010-11-14 02:36:52 +00:00
1 parent 83c040c481
commit e41b55cdf9
2 files changed
+12 -9

No files matched your search

@@ -113,16 +113,16 @@ public class ArgumentListBuilderTest extends Assert {
public void testToWindowsCommand() {
ArgumentListBuilder builder = new ArgumentListBuilder(
"ant.bat", "-Dfoo1=abc", // nothing special, no quotes
"-Dfoo2=foo bar", "-Dfoo3=/u*r", "-Dfoo4=/us?", // add quotes, no other escaping
"-Dfoo2=foo bar", "-Dfoo3=/u*r", "-Dfoo4=/us?", // add quotes
"-Dfoo10=bar,baz",
"-Dfoo5=foo;bar^baz", "-Dfoo6=<xml>&here;</xml>", // add quotes and ^ escaping
"-Dfoo7=foo|bar\"baz", // add quotes, ^| for | and "" for "
"-Dfoo5=foo;bar^baz", "-Dfoo6=<xml>&here;</xml>", // add quotes
"-Dfoo7=foo|bar\"baz", // add quotes and "" for "
"-Dfoo8=% %QED% %comspec% %-%(%.%", // add quotes, and extra quotes for %Q and %c
"-Dfoo9=%'''%%@%"); // no quotes as none of the % are followed by a letter
assertArrayEquals(new String[] { "cmd.exe", "/C",
"\"ant.bat -Dfoo1=abc \"-Dfoo2=foo bar\""
+ " \"-Dfoo3=/u*r\" \"-Dfoo4=/us?\" \"-Dfoo10=bar,baz\" \"-Dfoo5=foo;bar^^baz\""
+ " \"-Dfoo6=^<xml^>^&here;^</xml^>\" \"-Dfoo7=foo^|bar\"\"baz\""
+ " \"-Dfoo3=/u*r\" \"-Dfoo4=/us?\" \"-Dfoo10=bar,baz\" \"-Dfoo5=foo;bar^baz\""
+ " \"-Dfoo6=<xml>&here;</xml>\" \"-Dfoo7=foo|bar\"\"baz\""
+ " \"-Dfoo8=% %\"Q\"ED% %\"c\"omspec% %-%(%.%\""
+ " -Dfoo9=%'''%%@% && exit %%ERRORLEVEL%%\"" },
builder.toWindowsCommand().toCommandArray());