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..3ba620b297 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,7 @@ class SingleConfigurationTableEntry extends ConfigurationTableEntry { builder.append("|"); } else { - builder.append("|+++", this.description, "+++"); + builder.append("|+++", this.description.replace("|", "\\|"), "+++"); } } 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..ef84a2459e 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,20 @@ class SingleConfigurationTableEntryTests { + "|+++This is a description.+++" + NEWLINE); } + @Test + void descriptionWithPipe() { + ConfigurationMetadataProperty property = new ConfigurationMetadataProperty(); + property.setId("spring.test.prop"); + property.setDefaultValue("first\\second"); + 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 + "|`+first\\\\second+`" + NEWLINE + + "|+++This is a description with a \\| pipe.+++" + NEWLINE); + } + @Test void mapProperty() { ConfigurationMetadataProperty property = new ConfigurationMetadataProperty();