mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Support defaultHtmlEscape in WebFlux
See gh-36400 Signed-off-by: husseinvr97 <husseinmustafabas05@gmail.com>
This commit is contained in:
+23
-2
@@ -49,10 +49,17 @@ public final class MockServerWebExchange extends DefaultServerWebExchange {
|
||||
MockServerHttpRequest request, @Nullable WebSessionManager sessionManager,
|
||||
@Nullable ApplicationContext applicationContext, @Nullable Principal principal) {
|
||||
|
||||
this(request, sessionManager, applicationContext, null, principal);
|
||||
}
|
||||
|
||||
private MockServerWebExchange(
|
||||
MockServerHttpRequest request, @Nullable WebSessionManager sessionManager,
|
||||
@Nullable ApplicationContext applicationContext, @Nullable Boolean defaultHtmlEscape, @Nullable Principal principal) {
|
||||
|
||||
super(request, new MockServerHttpResponse(),
|
||||
sessionManager != null ? sessionManager : new DefaultWebSessionManager(),
|
||||
ServerCodecConfigurer.create(), new AcceptHeaderLocaleContextResolver(),
|
||||
applicationContext);
|
||||
applicationContext, defaultHtmlEscape);
|
||||
|
||||
this.principalMono = (principal != null) ? Mono.just(principal) : Mono.empty();
|
||||
}
|
||||
@@ -125,6 +132,8 @@ public final class MockServerWebExchange extends DefaultServerWebExchange {
|
||||
|
||||
private @Nullable ApplicationContext applicationContext;
|
||||
|
||||
private @Nullable Boolean defaultHtmlEscape;
|
||||
|
||||
private @Nullable Principal principal;
|
||||
|
||||
public Builder(MockServerHttpRequest request) {
|
||||
@@ -163,6 +172,18 @@ public final class MockServerWebExchange extends DefaultServerWebExchange {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default HTML escape setting for the exchange.
|
||||
* @param defaultHtmlEscape whether to enable default HTML escaping,
|
||||
* or {@code null} if not configured
|
||||
* @return this builder
|
||||
* @since 7.0.6
|
||||
*/
|
||||
public Builder defaultHtmlEscape(@Nullable Boolean defaultHtmlEscape) {
|
||||
this.defaultHtmlEscape = defaultHtmlEscape;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a user to associate with the exchange.
|
||||
* @param principal the principal to use
|
||||
@@ -178,7 +199,7 @@ public final class MockServerWebExchange extends DefaultServerWebExchange {
|
||||
*/
|
||||
public MockServerWebExchange build() {
|
||||
return new MockServerWebExchange(
|
||||
this.request, this.sessionManager, this.applicationContext, this.principal);
|
||||
this.request, this.sessionManager, this.applicationContext, this.defaultHtmlEscape, this.principal);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user