369349 replace quotes with a space escape method

This commit is contained in:
Greg Wilkins 2012-01-23 13:13:28 +11:00
parent 5c08b06622
commit bc5ac3622a
1 changed files with 14 additions and 13 deletions

View File

@ -664,39 +664,40 @@ public class Main
StringBuilder cmd = new StringBuilder();
cmd.append(findJavaBin());
for (String x : _jvmArgs) {
cmd.append(" \"").append(x).append("\"");
cmd.append(x);
}
cmd.append(" \"-Djetty.home=").append(_jettyHome).append("\"");
cmd.append(" -Djetty.home=").append(escapeSpaces(_jettyHome));
for (String p : _sysProps)
{
cmd.append(" \"-D").append(p);
cmd.append(" -D").append(p);
String v = System.getProperty(p);
if (v != null && v.length() > 0)
cmd.append('=').append(v);
cmd.append("\"");
cmd.append("=").append(escapeSpaces(v));
}
cmd.append(" -cp \"").append(classpath.toString()).append("\"");
cmd.append(" ").append(_config.getMainClassname());
cmd.append(" -cp ").append(classpath.toString());
cmd.append(" ").append(_config.getMainClassname());
// Check if we need to pass properties as a file
Properties properties = Config.getProperties();
if (properties.size() > 0)
{
File prop_file = File.createTempFile("start",".properties");
if (!_dryRun) {
if (!_dryRun)
prop_file.deleteOnExit();
}
properties.store(new FileOutputStream(prop_file),"start.jar properties");
cmd.append(" \"").append(prop_file.getAbsolutePath()).append("\"");
cmd.append(" ").append(escapeSpaces(prop_file.getAbsolutePath()));
}
for (String xml : xmls)
{
cmd.append(" \"").append(xml).append("\"");
}
cmd.append(" ").append(escapeSpaces(xml));
return cmd.toString();
}
private static String escapeSpaces(String s)
{
return s.replace(" ","\\ ");
}
private String findJavaBin()
{