Skip to content

Commit d172b22

Browse files
committed
Escape pipe symbol in properties changelog table cells
Closes gh-38515
1 parent 169070e commit d172b22

File tree

1 file changed

+13
-2
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata-changelog-generator/src/main/java/org/springframework/boot/configurationmetadata/changelog

1 file changed

+13
-2
lines changed

spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata-changelog-generator/src/main/java/org/springframework/boot/configurationmetadata/changelog/ChangelogWriter.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
* @author Stephane Nicoll
4747
* @author Andy Wilkinson
4848
* @author Phillip Webb
49+
* @author Moritz Halbritter
4950
*/
5051
class ChangelogWriter implements AutoCloseable {
5152

@@ -198,8 +199,18 @@ private String monospace(String value) {
198199
return (value != null) ? "`%s`".formatted(value) : null;
199200
}
200201

201-
private void writeCell(String format, Object... args) {
202-
write((format != null) ? "| %s%n".formatted(format) : "|%n", args);
202+
private void writeCell(String content) {
203+
if (content == null) {
204+
write("|%n");
205+
}
206+
else {
207+
String escaped = escapeForTableCell(content);
208+
write("| %s%n".formatted(escaped));
209+
}
210+
}
211+
212+
private String escapeForTableCell(String content) {
213+
return content.replace("|", "\\|");
203214
}
204215

205216
private void write(String format, Object... args) {

0 commit comments

Comments
 (0)