Skip to content

Commit 3bfe4dc

Browse files
committed
Switch responseEncodedHtmlEscape default to true
Issue: SPR-12369
1 parent 0a36559 commit 3bfe4dc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContext.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ else if (localeResolver != null) {
265265
// context-param in web.xml, if any.
266266
this.defaultHtmlEscape = WebUtils.getDefaultHtmlEscape(this.webApplicationContext.getServletContext());
267267

268+
// Determine response-encoded HTML escape setting from the "responseEncodedHtmlEscape"
269+
// context-param in web.xml, if any.
268270
this.responseEncodedHtmlEscape = WebUtils.getResponseEncodedHtmlEscape(this.webApplicationContext.getServletContext());
269271

270272
this.urlPathHelper = new UrlPathHelper();
@@ -491,11 +493,11 @@ public Boolean getDefaultHtmlEscape() {
491493
/**
492494
* Is HTML escaping using the response encoding by default?
493495
* If enabled, only XML markup significant characters will be escaped with UTF-* encodings.
494-
* <p>Falls back to {@code false} in case of no explicit default given.
496+
* <p>Falls back to {@code true} in case of no explicit default given, as of Spring 4.2.
495497
* @since 4.1.2
496498
*/
497499
public boolean isResponseEncodedHtmlEscape() {
498-
return (this.responseEncodedHtmlEscape != null && this.responseEncodedHtmlEscape.booleanValue());
500+
return (this.responseEncodedHtmlEscape == null || this.responseEncodedHtmlEscape.booleanValue());
499501
}
500502

501503
/**

0 commit comments

Comments
 (0)