Skip to content

Commit b9b8c25

Browse files
committed
[gh-11363] Preserve doubled quotes but strip single quotes
- Strip single quotes: "value" -> value - Preserve doubled quotes: ""value"" -> ""value"" - Always wrap final result in quotes for batch script safety
1 parent e2eddae commit b9b8c25

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

apache-maven/src/assembly/maven/bin/JvmConfigParser.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,17 @@ public static void main(String[] args) {
6969
line = line.replace("${MAVEN_PROJECTBASEDIR}", mavenProjectBasedir);
7070
line = line.replace("$MAVEN_PROJECTBASEDIR", mavenProjectBasedir);
7171

72-
// Strip outer quotes if present (they're just for grouping in jvm.config)
72+
// Strip outer single quotes if present (they're just for grouping in jvm.config)
73+
// But preserve already-doubled quotes (escaped quotes like ""value"")
7374
if (line.startsWith("\"") && line.endsWith("\"") && line.length() > 1) {
75+
// Check if it's NOT already escaped (doubled quotes at start/end)
76+
if (!(line.length() >= 4 && line.startsWith("\"\"") && line.endsWith("\"\""))) {
77+
line = line.substring(1, line.length() - 1);
78+
}
79+
} else if (line.startsWith("'") && line.endsWith("'") && line.length() > 1) {
7480
line = line.substring(1, line.length() - 1);
7581
}
7682

77-
// Quote the argument to protect special characters for batch script
78-
// Escape any quotes by doubling them (batch script convention)
79-
line = line.replace("\"", "\"\"");
80-
8183
// Append quoted argument with space separator
8284
if (result.length() > 0) {
8385
result.append(' ');

0 commit comments

Comments
 (0)