mirror of
https://github.com/apache/struts.git
synced 2026-08-07 23:57:03 +00:00
WW-4712 Escapes default message
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user