mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-09-29 09:28:53 +00:00
Escape values written to mvnd.properties
This commit is contained in:
@@ -93,8 +93,8 @@ public class Installer {
|
||||
static void writeMvndProperties(Path mvndPropsPath, Path mvndHome, Path javaHome) {
|
||||
LOG.info("Writing {}", mvndPropsPath);
|
||||
final String template = readTemplate();
|
||||
final String javaHomeLine = javaHome == null ? "" : "java.home = " + javaHome.toString();
|
||||
final String content = String.format(template, mvndHome.toString(), javaHomeLine);
|
||||
final String javaHomeLine = javaHome == null ? "" : "java.home = " + escape(javaHome.toString());
|
||||
final String content = String.format(template, escape(mvndHome.toString()), javaHomeLine);
|
||||
try {
|
||||
Files.write(mvndPropsPath, content.getBytes(StandardCharsets.UTF_8));
|
||||
} catch (IOException e) {
|
||||
@@ -102,6 +102,10 @@ public class Installer {
|
||||
}
|
||||
}
|
||||
|
||||
static String escape(String string) {
|
||||
return string.replace("\\", "\\\\");
|
||||
}
|
||||
|
||||
static String readTemplate() {
|
||||
try (InputStream in = Installer.class.getResourceAsStream("mvnd.properties.template");
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream(256)) {
|
||||
|
Reference in New Issue
Block a user