diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-docs/src/main/java/org/springframework/boot/configurationdocs/SingleConfigurationTableEntry.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-docs/src/main/java/org/springframework/boot/configurationdocs/SingleConfigurationTableEntry.java index 1d9d517a18..f1832a6944 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-docs/src/main/java/org/springframework/boot/configurationdocs/SingleConfigurationTableEntry.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-docs/src/main/java/org/springframework/boot/configurationdocs/SingleConfigurationTableEntry.java @@ -76,7 +76,8 @@ class SingleConfigurationTableEntry extends ConfigurationTableEntry { builder.append("|"); } else { - builder.append("|+++", this.description, "+++"); + String cleanedDescription = this.description.replace("|", "\\|"); + builder.append("|+++", cleanedDescription, "+++"); } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-docs/src/test/java/org/springframework/boot/configurationdocs/SingleConfigurationTableEntryTests.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-docs/src/test/java/org/springframework/boot/configurationdocs/SingleConfigurationTableEntryTests.java index 291310cdcb..8da4cc76c7 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-docs/src/test/java/org/springframework/boot/configurationdocs/SingleConfigurationTableEntryTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-docs/src/test/java/org/springframework/boot/configurationdocs/SingleConfigurationTableEntryTests.java @@ -86,6 +86,19 @@ class SingleConfigurationTableEntryTests { + "|+++This is a description.+++" + NEWLINE); } + @Test + void descriptionWithPipe() { + ConfigurationMetadataProperty property = new ConfigurationMetadataProperty(); + property.setId("spring.test.prop"); + property.setDescription("This is a description with a | pipe."); + property.setType("java.lang.String"); + SingleConfigurationTableEntry entry = new SingleConfigurationTableEntry(property); + AsciidocBuilder builder = new AsciidocBuilder(); + entry.write(builder); + assertThat(builder.toString()).isEqualTo("|`+spring.test.prop+`" + NEWLINE + "|" + NEWLINE + + "|+++This is a description with a \\| pipe.+++" + NEWLINE); + } + @Test void mapProperty() { ConfigurationMetadataProperty property = new ConfigurationMetadataProperty();