Support defaultHtmlEscape in WebFlux

See gh-36400

Signed-off-by: husseinvr97 <husseinmustafabas05@gmail.com>
This commit is contained in:
husseinvr97
2026-03-10 19:14:41 +00:00
committed by rstoyanchev
parent 104a2033c5
commit d4893fb32f
11 changed files with 212 additions and 14 deletions
@@ -127,6 +127,48 @@ class WebHttpHandlerBuilderTests {
assertThat(((HttpWebHandlerAdapter) builder.clone().build()).getApplicationContext()).isSameAs(context);
}
@Test
void defaultHtmlEscape() {
HttpHandler httpHandler = WebHttpHandlerBuilder
.webHandler(exchange -> Mono.empty())
.defaultHtmlEscape(true)
.build();
assertThat(httpHandler).isInstanceOf(HttpWebHandlerAdapter.class);
assertThat(((HttpWebHandlerAdapter) httpHandler).getDefaultHtmlEscape()).isTrue();
}
@Test
void defaultHtmlEscapeSetToFalse() {
HttpHandler httpHandler = WebHttpHandlerBuilder
.webHandler(exchange -> Mono.empty())
.defaultHtmlEscape(false)
.build();
assertThat(httpHandler).isInstanceOf(HttpWebHandlerAdapter.class);
assertThat(((HttpWebHandlerAdapter) httpHandler).getDefaultHtmlEscape()).isFalse();
}
@Test
void defaultHtmlEscapeNotConfigured() {
HttpHandler httpHandler = WebHttpHandlerBuilder
.webHandler(exchange -> Mono.empty())
.build();
assertThat(httpHandler).isInstanceOf(HttpWebHandlerAdapter.class);
assertThat(((HttpWebHandlerAdapter) httpHandler).getDefaultHtmlEscape()).isNull();
}
@Test
void cloneWithDefaultHtmlEscape() {
WebHttpHandlerBuilder builder = WebHttpHandlerBuilder
.webHandler(exchange -> Mono.empty())
.defaultHtmlEscape(true);
assertThat(((HttpWebHandlerAdapter) builder.build()).getDefaultHtmlEscape()).isTrue();
assertThat(((HttpWebHandlerAdapter) builder.clone().build()).getDefaultHtmlEscape()).isTrue();
}
@Test
void httpHandlerDecorator() {
BiFunction<ServerHttpRequest, String, ServerHttpRequest> mutator =