From bc5ac3622aa39b6e60b96ab24b0fb11c09535172 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Mon, 23 Jan 2012 13:13:28 +1100 Subject: [PATCH] 369349 replace quotes with a space escape method --- .../java/org/eclipse/jetty/start/Main.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java index 34715f9a7bd..a221c34eb60 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java @@ -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() {