Escape pipe symbol in properties changelog table cells

Closes gh-38515
This commit is contained in:
Moritz Halbritter 2023-11-30 11:37:25 +01:00
parent 169070ea1b
commit d172b22064

View File

@ -46,6 +46,7 @@ import org.springframework.boot.configurationmetadata.Deprecation;
* @author Stephane Nicoll
* @author Andy Wilkinson
* @author Phillip Webb
* @author Moritz Halbritter
*/
class ChangelogWriter implements AutoCloseable {
@ -198,8 +199,18 @@ class ChangelogWriter implements AutoCloseable {
return (value != null) ? "`%s`".formatted(value) : null;
}
private void writeCell(String format, Object... args) {
write((format != null) ? "| %s%n".formatted(format) : "|%n", args);
private void writeCell(String content) {
if (content == null) {
write("|%n");
}
else {
String escaped = escapeForTableCell(content);
write("| %s%n".formatted(escaped));
}
}
private String escapeForTableCell(String content) {
return content.replace("|", "\\|");
}
private void write(String format, Object... args) {