Correct handling of disable-html-escaping

See gh-39504
This commit is contained in:
Andy Wilkinson 2024-02-12 12:35:47 +00:00
parent 5746886e64
commit d597a4d56b
2 changed files with 3 additions and 3 deletions

View File

@ -93,7 +93,7 @@ public class GsonAutoConfiguration {
map.from(properties::getFieldNamingPolicy).to(builder::setFieldNamingPolicy);
map.from(properties::getPrettyPrinting).whenTrue().toCall(builder::setPrettyPrinting);
map.from(properties::getLenient).whenTrue().toCall(builder::setLenient);
map.from(properties::getDisableHtmlEscaping).whenFalse().toCall(builder::disableHtmlEscaping);
map.from(properties::getDisableHtmlEscaping).whenTrue().toCall(builder::disableHtmlEscaping);
map.from(properties::getDateFormat).to(builder::setDateFormat);
}

View File

@ -244,7 +244,7 @@ class GsonAutoConfigurationTests {
void withDisableHtmlEscapingTrue() {
this.contextRunner.withPropertyValues("spring.gson.disable-html-escaping:true").run((context) -> {
Gson gson = context.getBean(Gson.class);
assertThat(gson.htmlSafe()).isTrue();
assertThat(gson.htmlSafe()).isFalse();
});
}
@ -252,7 +252,7 @@ class GsonAutoConfigurationTests {
void withDisableHtmlEscapingFalse() {
this.contextRunner.withPropertyValues("spring.gson.disable-html-escaping:false").run((context) -> {
Gson gson = context.getBean(Gson.class);
assertThat(gson.htmlSafe()).isFalse();
assertThat(gson.htmlSafe()).isTrue();
});
}