WW-5022 Documents that setting escapeHtmlBody per tag takes precedence over global flag

This commit is contained in:
Lukasz Lenart
2022-01-04 19:49:01 +01:00
parent ecef56b546
commit 7a696523f0
2 changed files with 29 additions and 1 deletions
@@ -151,6 +151,11 @@ struts.ui.theme.expansion.token=~~~
### Sets the default template type. Either ftl, vm, or jsp
struts.ui.templateSuffix=ftl
### Sets a global flag which will escape html body of Anchor, Submit and Component tag
### You can control this flag per tag, e.g.: <s:a ... escapeHtmlTag="true">...</s:a>
### and this take precedence over the global flag
# struts.ui.escapeHtmlBody=true
### Configuration reloading
### This will cause the configuration to reload struts.xml when it is changed
# struts.configuration.xml.reload=false
@@ -230,7 +235,7 @@ struts.handle.exception=true
### Applies maximum length allowed on OGNL expressions for security enhancement (optional)
###
### **WARNING**: If developers enable this option (by configuration) they should make sure that they understand the implications of setting
### **WARNING**: If developers enable this option (by configuration) they should make sure that they understand the implications of setting
### struts.ognl.expressionMaxLength. They must choose a value large enough to permit ALL valid OGNL expressions used within the application.
### Values larger than the 200-400 range have diminishing security value (at which point it is really only a "style guard" for long OGNL
### expressions in an application. Setting a value of null or "" will also disable the feature.
@@ -298,4 +298,27 @@ public class AnchorTest extends AbstractUITagTest {
tag.doEndTag();
}
public void testTagAttributeTakesPrecedenceOverInjectEscapeHtmlBodyFlag() throws Exception {
// given
initDispatcherWithConfigs("struts-default.xml, struts-escape-body.xml");
String escapeHtmlBody = container.getInstance(String.class, StrutsConstants.STRUTS_UI_ESCAPE_HTML_BODY);
assertEquals("true", escapeHtmlBody);
createMocks();
createAction();
AnchorTag tag = createTag();
tag.setEscapeHtmlBody("false");
// when
tag.doStartTag();
// then
Anchor component = (Anchor) tag.getComponent();
assertFalse(component.escapeHtmlBody());
tag.doEndTag();
}
}