From 8e0b8750c05e788c76bcf1298e2856adc53b4ce6 Mon Sep 17 00:00:00 2001 From: Robert Thornton Date: Mon, 7 Dec 2015 17:15:10 -0700 Subject: [PATCH] Cleanup description new-lines for launch script Replace all new-line characters in multi-line pom descriptions before inserting into the launcher script. Prior to this commit the shell would attempt to execut the extra lines, for example: A multi-line pom description that could do something terrible: rm -r foo Closes gh-4703 --- .../org/springframework/boot/maven/RepackageMojo.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java index 90cc5033c89..a74f4288b61 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java +++ b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java @@ -261,11 +261,16 @@ public class RepackageMojo extends AbstractDependencyFilterMojo { putIfMissing(properties, "initInfoProvides", this.project.getArtifactId()); putIfMissing(properties, "initInfoShortDescription", this.project.getName(), this.project.getArtifactId()); - putIfMissing(properties, "initInfoDescription", this.project.getDescription(), - this.project.getName(), this.project.getArtifactId()); + putIfMissing(properties, "initInfoDescription", + removeLineBreaks(this.project.getDescription()), this.project.getName(), + this.project.getArtifactId()); return properties; } + private String removeLineBreaks(String description) { + return description.replaceAll("\\s+", " "); + } + private void putIfMissing(Properties properties, String key, String... valueCandidates) { if (!properties.containsKey(key)) {