You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2016/11/11 10:57:39 UTC
[1/3] struts git commit: WW-4711 Disables evaluating ValueStack by
default
Repository: struts
Updated Branches:
refs/heads/master ab6750211 -> 366366cdd
WW-4711 Disables evaluating ValueStack by default
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/996475d7
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/996475d7
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/996475d7
Branch: refs/heads/master
Commit: 996475d755820914ea4695729ec46159f12625e0
Parents: ab67502
Author: Lukasz Lenart <lu...@apache.org>
Authored: Fri Nov 11 11:52:40 2016 +0100
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Fri Nov 11 11:52:40 2016 +0100
----------------------------------------------------------------------
.../java/org/apache/struts2/components/Text.java | 18 ++++++++++++------
.../org/apache/struts2/views/jsp/TextTagTest.java | 6 +++---
2 files changed, 15 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/996475d7/core/src/main/java/org/apache/struts2/components/Text.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/components/Text.java b/core/src/main/java/org/apache/struts2/components/Text.java
index 69c0344..3f7c15e 100644
--- a/core/src/main/java/org/apache/struts2/components/Text.java
+++ b/core/src/main/java/org/apache/struts2/components/Text.java
@@ -51,7 +51,7 @@ import java.util.List;
*
* <p>
* If the named message is not found in a property file, then the body of the
- * tag will be used as default message. If no body is used, then the stack will
+ * tag will be used as default message. If no body is used, then the stack can
* be searched, and if a value is returned, it will written to the output.
* If no value is found on the stack, the key of the message will be written out.
* </p>
@@ -115,9 +115,10 @@ import java.util.List;
tldTagClass="org.apache.struts2.views.jsp.TextTag",
description="Render a I18n text message")
public class Text extends ContextBean implements Param.UnnamedParametric {
+
private static final Logger LOG = LogManager.getLogger(Text.class);
- protected List values = Collections.EMPTY_LIST;
+ protected List<Object> values = Collections.emptyList();
protected String actualName;
protected String name;
protected String searchStack;
@@ -131,7 +132,7 @@ public class Text extends ContextBean implements Param.UnnamedParametric {
this.name = name;
}
- @StrutsTagAttribute(description="Search the stack if property is not found on resources", type = "Boolean", defaultValue = "true")
+ @StrutsTagAttribute(description="Search the stack if property is not found on resources", type = "Boolean", defaultValue = "false")
public void setSearchValueStack(String searchStack) {
this.searchStack = searchStack;
}
@@ -152,8 +153,13 @@ public class Text extends ContextBean implements Param.UnnamedParametric {
defaultMessage = actualName;
}
- Boolean doSearchStack = searchStack != null ? (Boolean) findValue(searchStack, Boolean.class) : true;
- String msg = TextProviderHelper.getText(actualName, defaultMessage, values, getStack(), doSearchStack == null || doSearchStack);
+ Boolean doSearchStack = false;
+ if (searchStack != null) {
+ Object value = findValue(searchStack, Boolean.class);
+ doSearchStack = value != null ? (Boolean) value : false;
+ }
+
+ String msg = TextProviderHelper.getText(actualName, defaultMessage, values, getStack(), doSearchStack);
if (msg != null) {
try {
@@ -176,7 +182,7 @@ public class Text extends ContextBean implements Param.UnnamedParametric {
public void addParameter(Object value) {
if (values.isEmpty()) {
- values = new ArrayList(4);
+ values = new ArrayList<>(4);
}
values.add(value);
http://git-wip-us.apache.org/repos/asf/struts/blob/996475d7/core/src/test/java/org/apache/struts2/views/jsp/TextTagTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/views/jsp/TextTagTest.java b/core/src/test/java/org/apache/struts2/views/jsp/TextTagTest.java
index 651fa3d..729ecaf 100644
--- a/core/src/test/java/org/apache/struts2/views/jsp/TextTagTest.java
+++ b/core/src/test/java/org/apache/struts2/views/jsp/TextTagTest.java
@@ -218,10 +218,11 @@ public class TextTagTest extends AbstractTagTest {
assertEquals(value_int, writer.toString());
}
- public void testTextTagSearchesStackByDefault() throws JspException {
+ public void testTextTagCanSearchStackToFindValue() throws JspException {
String key = "result";
tag.setName(key);
+ tag.setSearchValueStack("true");
final StringBuffer buffer = writer.getBuffer();
buffer.delete(0, buffer.length());
ValueStack newStack = container.getInstance(ValueStackFactory.class).createValueStack();
@@ -238,11 +239,10 @@ public class TextTagTest extends AbstractTagTest {
assertEquals("bar", writer.toString());
}
- public void testTextTagDoNotSearchStack() throws JspException {
+ public void testTextTagDoNotSearchStackByDefault() throws JspException {
String key = "result";
tag.setName(key);
- tag.setSearchValueStack("false");
final StringBuffer buffer = writer.getBuffer();
buffer.delete(0, buffer.length());
ValueStack newStack = container.getInstance(ValueStackFactory.class).createValueStack();
[3/3] struts git commit: WW-4712 Escapes default message
Posted by lu...@apache.org.
WW-4712 Escapes default message
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/366366cd
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/366366cd
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/366366cd
Branch: refs/heads/master
Commit: 366366cdd8bbb129eaad05eb00dfca6e09afac05
Parents: 4e7a4b1
Author: Lukasz Lenart <lu...@apache.org>
Authored: Fri Nov 11 11:57:29 2016 +0100
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Fri Nov 11 11:57:29 2016 +0100
----------------------------------------------------------------------
.../main/java/org/apache/struts2/util/TextProviderHelper.java | 4 ++++
core/src/test/java/org/apache/struts2/views/jsp/TextTagTest.java | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/366366cd/core/src/main/java/org/apache/struts2/util/TextProviderHelper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/util/TextProviderHelper.java b/core/src/main/java/org/apache/struts2/util/TextProviderHelper.java
index 1c19a2f..c6e9679 100644
--- a/core/src/main/java/org/apache/struts2/util/TextProviderHelper.java
+++ b/core/src/main/java/org/apache/struts2/util/TextProviderHelper.java
@@ -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()) {
http://git-wip-us.apache.org/repos/asf/struts/blob/366366cd/core/src/test/java/org/apache/struts2/views/jsp/TextTagTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/views/jsp/TextTagTest.java b/core/src/test/java/org/apache/struts2/views/jsp/TextTagTest.java
index 729ecaf..661acd3 100644
--- a/core/src/test/java/org/apache/struts2/views/jsp/TextTagTest.java
+++ b/core/src/test/java/org/apache/struts2/views/jsp/TextTagTest.java
@@ -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());
[2/3] struts git commit: WW-4711 Disables evaluating ValueStack by
default
Posted by lu...@apache.org.
WW-4711 Disables evaluating ValueStack by default
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/4e7a4b18
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/4e7a4b18
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/4e7a4b18
Branch: refs/heads/master
Commit: 4e7a4b18c0286c34b55529d2db1346df9a7f9dde
Parents: 996475d
Author: Lukasz Lenart <lu...@apache.org>
Authored: Fri Nov 11 11:57:04 2016 +0100
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Fri Nov 11 11:57:04 2016 +0100
----------------------------------------------------------------------
core/src/site/resources/tags/text.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/4e7a4b18/core/src/site/resources/tags/text.html
----------------------------------------------------------------------
diff --git a/core/src/site/resources/tags/text.html b/core/src/site/resources/tags/text.html
index 06ee7be..bd2e511 100644
--- a/core/src/site/resources/tags/text.html
+++ b/core/src/site/resources/tags/text.html
@@ -44,7 +44,7 @@ Please do not edit it directly.
<tr>
<td align="left" valign="top">searchValueStack</td>
<td align="left" valign="top">false</td>
- <td align="left" valign="top">true</td>
+ <td align="left" valign="top">false</td>
<td align="left" valign="top">false</td>
<td align="left" valign="top">Boolean</td>
<td align="left" valign="top">Search the stack if property is not found on resources</td>