WW-4712 Escapes default message

This commit is contained in:
Lukasz Lenart
2016-11-11 11:57:29 +01:00
parent 4e7a4b18c0
commit 366366cdd8
2 changed files with 5 additions and 1 deletions
@@ -23,6 +23,7 @@ package org.apache.struts2.util;
import com.opensymphony.xwork2.TextProvider;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -86,6 +87,9 @@ public class TextProviderHelper {
if (msg == null) {
// use the defaultMessage literal value
msg = defaultMessage;
msg = StringEscapeUtils.escapeEcmaScript(msg);
msg = StringEscapeUtils.escapeHtml4(msg);
LOG.debug("Message for key '{}' is null, returns escaped default message [{}]", key, msg);
}
if (LOG.isWarnEnabled()) {
@@ -274,7 +274,7 @@ public class TextTagTest extends AbstractTagTest {
public void testWithNoMessageAndNoDefaultKeyReturned() throws JspException {
final String key = "key.does.not.exist";
tag.setName("'" + key + "'");
tag.setName(key);
tag.doStartTag();
tag.doEndTag();
assertEquals(key, writer.toString());