mirror of
https://github.com/apache/struts.git
synced 2026-08-08 08:07:17 +00:00
Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5c61c9a575 | |||
| e40dcaa3f4 | |||
| ab6acd2382 | |||
| bf0a01d390 | |||
| 00c47b7ce6 | |||
| c84810ff82 | |||
| 2ea59b31b4 | |||
| fae1e0e799 | |||
| e4ce3ce839 | |||
| 730441b7a7 | |||
| bb22c585b5 | |||
| eccc31ebce | |||
| 1c92a8b2c9 | |||
| b28b78c062 | |||
| 8d172b8e9b | |||
| 88b885339a | |||
| 3f526d630a | |||
| 34025eafec | |||
| 54e8bf1f75 | |||
| 9f2cae2f1e | |||
| 9bcd1bc9f6 | |||
| f052398cd2 | |||
| 237432512d | |||
| ca25476120 | |||
| 731fde544c | |||
| 76eb8f38a3 | |||
| deefeffd11 | |||
| 98d2692e43 | |||
| 46517afb14 | |||
| 5190b53673 | |||
| d36f31b3e1 | |||
| cbae13a6a8 | |||
| 865f1f2784 | |||
| 5ce807aaea | |||
| 17dab897d9 | |||
| 45fa8d0320 | |||
| 6fee2eb1a4 |
+1
-1
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-blank</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-jboss-blank</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-mailreader</artifactId>
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-portlet</artifactId>
|
||||
|
||||
@@ -5,11 +5,11 @@ Here you'll find examples of what is possible with the Struts Portlet integratio
|
||||
<ul>
|
||||
<li><a href="<s:url action="formExample"/>">A simple form</a></li>
|
||||
<li><a href="<s:url action="formExamplePrg" method="input"/>">Form example with proper PRG</a></li>
|
||||
<li><a href="<s:url action="formExampleModelDriven" method="input"/>">Model driven example</li>
|
||||
<li><a href="<s:url action="formExampleModelDriven" method="input"/>">Model driven example</a>/li>
|
||||
<li><a href="<s:url action="validationExample"/>">Validation</a></li>
|
||||
<li><a href="<s:url action="tokenExample"/>">Token</a></li>
|
||||
<li><a href="<s:url action="springExample"/>">Spring integration</a></li>
|
||||
<li><a href="<s:url action="fileUpload" method="input"/>">File upload</li>
|
||||
<li><a href="<s:url action="fileUpload" method="input"/>">File upload</a></li>
|
||||
<li><a href="<s:url action="freeMarkerExample"/>">FreeMarker</a></li>
|
||||
<li><a href="<s:url action="velocityHelloWorld"/>">Velocity</a></li>
|
||||
<li><a href="<s:url action="index" namespace="/tiles"/>">Form Example Validation with Tiles</a></li>
|
||||
|
||||
@@ -26,12 +26,12 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-rest-showcase</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
<name>Struts 2 Rest Showcase Webapp</name>
|
||||
<description>Struts 2 Rest Showcase Example</description>
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-showcase</artifactId>
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-archetypes</artifactId>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-archetypes</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-archetypes</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-archetypes</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-archetypes</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-archetypes</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-archetypes</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-archetypes</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-assembly</artifactId>
|
||||
|
||||
+3
-3
@@ -10,7 +10,7 @@
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-bom</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Struts 2 Bill of Materials</name>
|
||||
@@ -25,7 +25,7 @@
|
||||
</licenses>
|
||||
|
||||
<properties>
|
||||
<struts-version.version>2.3.28</struts-version.version>
|
||||
<struts-version.version>2.3.30</struts-version.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
@@ -197,6 +197,6 @@
|
||||
</dependencyManagement>
|
||||
|
||||
<scm>
|
||||
<tag>STRUTS_2_3_28</tag>
|
||||
<tag>STRUTS_2_3_30</tag>
|
||||
</scm>
|
||||
</project>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-osgi-bundles</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-osgi-admin-bundle</artifactId>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-osgi-bundles</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-osgi-demo-bundle</artifactId>
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-osgi-bundles</artifactId>
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
<artifactId>struts2-core</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -22,14 +22,12 @@
|
||||
package org.apache.struts2.components;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.LocaleProvider;
|
||||
import com.opensymphony.xwork2.TextProviderFactory;
|
||||
import com.opensymphony.xwork2.TextProvider;
|
||||
@@ -95,6 +93,8 @@ public class I18n extends Component {
|
||||
protected String name;
|
||||
protected Container container;
|
||||
private TextProvider textProvider;
|
||||
private TextProvider defaultTextProvider;
|
||||
private LocaleProvider localeProvider;
|
||||
|
||||
public I18n(ValueStack stack) {
|
||||
super(stack);
|
||||
@@ -105,26 +105,31 @@ public class I18n extends Component {
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setTextProvider(TextProvider textProvider) {
|
||||
this.defaultTextProvider = textProvider;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setLocaleProvider(LocaleProvider localeProvider) {
|
||||
this.localeProvider = localeProvider;
|
||||
}
|
||||
|
||||
public boolean start(Writer writer) {
|
||||
boolean result = super.start(writer);
|
||||
|
||||
try {
|
||||
String name = this.findString(this.name, "name", "Resource bundle name is required. Example: foo or foo_en");
|
||||
ResourceBundle bundle = (ResourceBundle) findValue("getTexts('" + name + "')");
|
||||
ResourceBundle bundle = defaultTextProvider.getTexts(name);
|
||||
|
||||
if (bundle == null) {
|
||||
bundle = LocalizedTextUtil.findResourceBundle(name, (Locale) getStack().getContext().get(ActionContext.LOCALE));
|
||||
bundle = LocalizedTextUtil.findResourceBundle(name, localeProvider.getLocale());
|
||||
}
|
||||
|
||||
if (bundle != null) {
|
||||
final Locale locale = (Locale) getStack().getContext().get(ActionContext.LOCALE);
|
||||
TextProviderFactory tpf = new TextProviderFactory();
|
||||
container.inject(tpf);
|
||||
textProvider = tpf.createInstance(bundle, new LocaleProvider() {
|
||||
public Locale getLocale() {
|
||||
return locale;
|
||||
}
|
||||
});
|
||||
textProvider = tpf.createInstance(bundle, localeProvider);
|
||||
getStack().push(textProvider);
|
||||
pushed = true;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.struts2.RequestUtils;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.StrutsException;
|
||||
import org.apache.struts2.util.PrefixTrie;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -136,7 +137,7 @@ public class DefaultActionMapper implements ActionMapper {
|
||||
put(METHOD_PREFIX, new ParameterAction() {
|
||||
public void execute(String key, ActionMapping mapping) {
|
||||
if (allowDynamicMethodCalls) {
|
||||
mapping.setMethod(key.substring(METHOD_PREFIX.length()));
|
||||
mapping.setMethod(cleanupActionName(key.substring(METHOD_PREFIX.length())));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -148,7 +149,7 @@ public class DefaultActionMapper implements ActionMapper {
|
||||
if (allowDynamicMethodCalls) {
|
||||
int bang = name.indexOf('!');
|
||||
if (bang != -1) {
|
||||
String method = name.substring(bang + 1);
|
||||
String method = cleanupActionName(name.substring(bang + 1));
|
||||
mapping.setMethod(method);
|
||||
name = name.substring(0, bang);
|
||||
}
|
||||
@@ -384,18 +385,7 @@ public class DefaultActionMapper implements ActionMapper {
|
||||
if (allowedActionNames.matcher(rawActionName).matches()) {
|
||||
return rawActionName;
|
||||
} else {
|
||||
if (LOG.isWarnEnabled()) {
|
||||
LOG.warn("Action [#0] does not match allowed action names pattern [#1], cleaning it up!",
|
||||
rawActionName, allowedActionNames);
|
||||
}
|
||||
String cleanActionName = rawActionName;
|
||||
for (String chunk : allowedActionNames.split(rawActionName)) {
|
||||
cleanActionName = cleanActionName.replace(chunk, "");
|
||||
}
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Cleaned action name [#0]", cleanActionName);
|
||||
}
|
||||
return cleanActionName;
|
||||
throw new StrutsException("Action [" + rawActionName + "] does not match allowed action names pattern [" + allowedActionNames + "]!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -72,8 +72,7 @@ class MessageStorePreResultListener implements PreResultListener {
|
||||
try {
|
||||
ResultConfig resultConfig = invocation.getProxy().getConfig().getResults().get(resultCode);
|
||||
if (resultConfig != null) {
|
||||
isRedirect = ServletRedirectResult.class.getName().equals(resultConfig.getClassName())
|
||||
|| ServletActionRedirectResult.class.getName().equals(resultConfig.getClassName());
|
||||
isRedirect = ServletRedirectResult.class.isAssignableFrom(Class.forName(resultConfig.getClassName()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Cannot read result!", e);
|
||||
|
||||
@@ -448,12 +448,7 @@ public class XSLTResult implements Result {
|
||||
ServletActionContext.getServletContext());
|
||||
}
|
||||
|
||||
protected Templates getTemplates(String path) throws TransformerException, IOException {
|
||||
String pathFromRequest = ServletActionContext.getRequest().getParameter("xslt.location");
|
||||
|
||||
if (pathFromRequest != null)
|
||||
path = pathFromRequest;
|
||||
|
||||
protected Templates getTemplates(final String path) throws TransformerException, IOException {
|
||||
if (path == null)
|
||||
throw new TransformerException("Stylesheet path is null");
|
||||
|
||||
|
||||
@@ -50,6 +50,8 @@
|
||||
ognl.OgnlContext,
|
||||
ognl.ClassResolver,
|
||||
ognl.TypeConverter,
|
||||
ognl.MemberAccess,
|
||||
ognl.DefaultMemberAccess,
|
||||
com.opensymphony.xwork2.ognl.SecurityMemberAccess,
|
||||
com.opensymphony.xwork2.ActionContext" />
|
||||
|
||||
|
||||
@@ -61,6 +61,9 @@
|
||||
</#if>
|
||||
<#else>
|
||||
<input type="submit"<#rt/>
|
||||
<#if parameters.nameValue?has_content>
|
||||
value="<@s.property value="parameters.nameValue"/>"<#rt/>
|
||||
</#if>
|
||||
</#if>
|
||||
<#if parameters.id?has_content>
|
||||
id="${parameters.id?html}"<#rt/>
|
||||
@@ -68,9 +71,6 @@
|
||||
<#if parameters.name?has_content>
|
||||
name="${parameters.name?html}"<#rt/>
|
||||
</#if>
|
||||
<#if parameters.nameValue?has_content>
|
||||
value="<@s.property value="parameters.nameValue"/>"<#rt/>
|
||||
</#if>
|
||||
<#if parameters.disabled!false>
|
||||
disabled="disabled"<#rt/>
|
||||
</#if>
|
||||
|
||||
@@ -164,21 +164,4 @@ public class UIBeanTest extends StrutsInternalTestCase {
|
||||
assertEquals("12", txtFld.getTheme());
|
||||
}
|
||||
|
||||
// I couldn't figure out how to make this test work. Bailing for now.
|
||||
// public void testEscapeLabel() throws Exception {
|
||||
// ValueStack stack = ActionContext.getContext().getValueStack();
|
||||
// MockHttpServletRequest req = new MockHttpServletRequest();
|
||||
// MockHttpServletResponse res = new MockHttpServletResponse();
|
||||
// stack.push(this);
|
||||
//
|
||||
// TextField txtFld = new TextField(stack, req, res);
|
||||
// txtFld.setKey("test['foo']");
|
||||
// txtFld.evaluateParams();
|
||||
// assertEquals("test_label", txtFld.getParameters().get("label"));
|
||||
// }
|
||||
//
|
||||
// public String getText(String key) {
|
||||
// assertEquals("test[\\'foo\\']", key);
|
||||
// return "test_label";
|
||||
// }
|
||||
}
|
||||
|
||||
+30
-6
@@ -30,6 +30,7 @@ import com.opensymphony.xwork2.config.ConfigurationManager;
|
||||
import com.opensymphony.xwork2.config.entities.PackageConfig;
|
||||
import com.opensymphony.xwork2.config.impl.DefaultConfiguration;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.StrutsException;
|
||||
import org.apache.struts2.StrutsInternalTestCase;
|
||||
import org.apache.struts2.dispatcher.StrutsResultSupport;
|
||||
import org.apache.struts2.views.jsp.StrutsMockHttpServletRequest;
|
||||
@@ -162,8 +163,8 @@ public class DefaultActionMapperTest extends StrutsInternalTestCase {
|
||||
|
||||
public void testGetMappingWithNamespaceSlash() throws Exception {
|
||||
|
||||
req.setupGetRequestURI("/my.hh/abc.action");
|
||||
req.setupGetServletPath("/my.hh/abc.action");
|
||||
req.setupGetRequestURI("/my-hh/abc.action");
|
||||
req.setupGetServletPath("/my-hh/abc.action");
|
||||
req.setupGetAttribute(null);
|
||||
req.addExpectedGetAttributeName("javax.servlet.include.servlet_path");
|
||||
|
||||
@@ -180,7 +181,7 @@ public class DefaultActionMapperTest extends StrutsInternalTestCase {
|
||||
mapping = mapper.getMapping(req, configManager);
|
||||
|
||||
assertEquals("", mapping.getNamespace());
|
||||
assertEquals("my.hh/abc", mapping.getName());
|
||||
assertEquals("my-hh/abc", mapping.getName());
|
||||
}
|
||||
|
||||
public void testGetMappingWithUnknownNamespace() throws Exception {
|
||||
@@ -844,14 +845,37 @@ public class DefaultActionMapperTest extends StrutsInternalTestCase {
|
||||
String actionName = "action";
|
||||
assertEquals(actionName, mapper.cleanupActionName(actionName));
|
||||
|
||||
Throwable expected = null;
|
||||
|
||||
actionName = "${action}";
|
||||
assertEquals("action", mapper.cleanupActionName(actionName));
|
||||
try {
|
||||
mapper.cleanupActionName(actionName);
|
||||
fail();
|
||||
} catch (Throwable t) {
|
||||
expected = t;
|
||||
}
|
||||
assertTrue(expected instanceof StrutsException);
|
||||
assertEquals("Action [${action}] does not match allowed action names pattern [" + mapper.allowedActionNames.pattern() + "]!", expected.getMessage());
|
||||
|
||||
actionName = "${${%{action}}}";
|
||||
assertEquals("action", mapper.cleanupActionName(actionName));
|
||||
try {
|
||||
mapper.cleanupActionName(actionName);
|
||||
fail();
|
||||
} catch (Throwable t) {
|
||||
expected = t;
|
||||
}
|
||||
assertTrue(expected instanceof StrutsException);
|
||||
assertEquals("Action [${${%{action}}}] does not match allowed action names pattern [" + mapper.allowedActionNames.pattern() + "]!", expected.getMessage());
|
||||
|
||||
actionName = "${#foo='action',#foo}";
|
||||
assertEquals("fooactionfoo", mapper.cleanupActionName(actionName));
|
||||
try {
|
||||
mapper.cleanupActionName(actionName);
|
||||
fail();
|
||||
} catch (Throwable t) {
|
||||
expected = t;
|
||||
}
|
||||
assertTrue(expected instanceof StrutsException);
|
||||
assertEquals("Action [${#foo='action',#foo}] does not match allowed action names pattern [" + mapper.allowedActionNames.pattern() + "]!", expected.getMessage());
|
||||
|
||||
actionName = "test-action";
|
||||
assertEquals("test-action", mapper.cleanupActionName(actionName));
|
||||
|
||||
@@ -237,7 +237,7 @@ public class SubmitTest extends AbstractUITagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals("<input type=\"submit\" id=\"myname\" name=\"myname\" value=\"Submit\"/>", writer.toString().trim());
|
||||
assertEquals("<input type=\"submit\" value=\"Submit\" id=\"myname\" name=\"myname\"/>", writer.toString().trim());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -281,4 +281,20 @@ public class TextfieldTest extends AbstractUITagTest {
|
||||
verify(TextFieldTag.class.getResource("Textfield-11.txt"));
|
||||
}
|
||||
|
||||
public void testNameEvaluation() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setArray(new String[]{"test", "bar"});
|
||||
testAction.setFooInt(1);
|
||||
|
||||
TextFieldTag tag = new TextFieldTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("array[%{fooInt}]");
|
||||
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
verify(TextFieldTag.class.getResource("Textfield-12.txt"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<tr>
|
||||
<td colspan="2"><div align="left"><input type="submit" id="myname" name="myname" value="bar" disabled="disabled" tabindex="1"/></div></td>
|
||||
<td colspan="2"><div align="left"><input type="submit" value="bar" id="myname" name="myname" disabled="disabled" tabindex="1"/></div></td>
|
||||
</tr>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<tr>
|
||||
<td colspan="2"><div align="right"><input type="submit" id="myname" name="myname" value="Submit" title="mytitle"/></div></td>
|
||||
<td colspan="2"><div align="right"><input type="submit" value="Submit" id="myname" name="myname" title="mytitle"/></div></td>
|
||||
</tr>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<tr>
|
||||
<td colspan="2"><div align="right"><input type="image" alt="bar" id="myname" name="myname" value="bar" disabled="disabled"/></div></td>
|
||||
<td colspan="2"><div align="right"><input type="image" alt="bar" id="myname" name="myname" disabled="disabled"/></div></td>
|
||||
</tr>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<tr>
|
||||
<td colspan="2"><div align="right"><input type="image" alt="mylabel" src="some.gif" id="myname" name="myname" value="bar"/></div></td>
|
||||
<td colspan="2"><div align="right"><input type="image" alt="mylabel" src="some.gif" id="myname" name="myname"/></div></td>
|
||||
</tr>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<tr>
|
||||
<td class="tdLabel"></td>
|
||||
<td><input type="text" name="array[1]" value="bar" id="array_1_"/></td>
|
||||
</tr>
|
||||
+1
-1
@@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-cdi-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-codebehind-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-config-browser-plugin</artifactId>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-convention-plugin</artifactId>
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-dwr-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-embeddedjsp-plugin</artifactId>
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-gxp-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-jasperreports-plugin</artifactId>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-java8-support-plugin</artifactId>
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-javatemplates-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-jfreechart-plugin</artifactId>
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-jsf-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-json-plugin</artifactId>
|
||||
|
||||
@@ -7,7 +7,9 @@ import org.junit.Test;
|
||||
|
||||
import java.net.URL;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
@@ -90,6 +92,41 @@ public class JSONWriterTest extends StrutsTestCase{
|
||||
TestUtils.assertEquals(JSONWriter.class.getResource("jsonwriter-write-bean-02.txt"), json);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWriteBeanWithList() throws Exception {
|
||||
BeanWithList bean1 = new BeanWithList();
|
||||
bean1.setStringField("str");
|
||||
bean1.setBooleanField(true);
|
||||
bean1.setCharField('s');
|
||||
bean1.setDoubleField(10.1);
|
||||
bean1.setFloatField(1.5f);
|
||||
bean1.setIntField(10);
|
||||
bean1.setLongField(100);
|
||||
bean1.setEnumField(AnEnum.ValueA);
|
||||
bean1.setEnumBean(AnEnumBean.Two);
|
||||
List<String> errors = new ArrayList<String>();
|
||||
errors.add("Field is required");
|
||||
bean1.setErrors(errors);
|
||||
|
||||
JSONWriter jsonWriter = new JSONWriter();
|
||||
jsonWriter.setEnumAsBean(false);
|
||||
jsonWriter.setIgnoreHierarchy(false);
|
||||
String json = jsonWriter.write(bean1);
|
||||
TestUtils.assertEquals(JSONWriter.class.getResource("jsonwriter-write-bean-04.txt"), json);
|
||||
}
|
||||
|
||||
private class BeanWithList extends Bean {
|
||||
private List<String> errors;
|
||||
|
||||
public List<String> getErrors() {
|
||||
return errors;
|
||||
}
|
||||
|
||||
public void setErrors(List<String> errors) {
|
||||
this.errors = errors;
|
||||
}
|
||||
}
|
||||
|
||||
private class AnnotatedBean extends Bean{
|
||||
private URL url;
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"bigDecimal":null,
|
||||
"bigInteger":null,
|
||||
"booleanField":true,
|
||||
"byteField":0,
|
||||
"charField":"s",
|
||||
"doubleField":10.1,
|
||||
"enumBean":"Two",
|
||||
"enumField":"ValueA",
|
||||
"errors":["Field is required"],
|
||||
"floatField":1.5,
|
||||
"intField":10,
|
||||
"longField":100,
|
||||
"objectField":null,
|
||||
"stringField":"str"
|
||||
}
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-junit-plugin</artifactId>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-osgi-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-oval-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-pell-multipart-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-plexus-plugin</artifactId>
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-portlet-tiles-plugin</artifactId>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-portlet-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-rest-plugin</artifactId>
|
||||
|
||||
@@ -311,7 +311,7 @@ public class RestActionMapper extends DefaultActionMapper {
|
||||
|
||||
mapping.setName(actionName);
|
||||
if (allowDynamicMethodCalls) {
|
||||
mapping.setMethod(actionMethod);
|
||||
mapping.setMethod(cleanupActionName(actionMethod));
|
||||
} else {
|
||||
mapping.setMethod(null);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-sitegraph-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-sitemesh-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-spring-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-struts1-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-testng-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-tiles-plugin</artifactId>
|
||||
|
||||
+15
-4
@@ -63,6 +63,8 @@ import org.apache.tiles.renderer.impl.ChainedDelegateAttributeRenderer;
|
||||
import org.apache.tiles.servlet.context.ServletUtil;
|
||||
import org.apache.tiles.util.URLUtil;
|
||||
|
||||
import com.opensymphony.xwork2.util.TextParseUtil;
|
||||
|
||||
import javax.el.ArrayELResolver;
|
||||
import javax.el.BeanELResolver;
|
||||
import javax.el.CompositeELResolver;
|
||||
@@ -73,6 +75,7 @@ import javax.el.ResourceBundleELResolver;
|
||||
import javax.servlet.ServletContext;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -201,7 +204,12 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory {
|
||||
@Override
|
||||
protected List<URL> getSourceURLs(TilesApplicationContext applicationContext, TilesRequestContextFactory contextFactory) {
|
||||
try {
|
||||
Set<URL> finalSet = applicationContext.getResources(getTilesDefinitionPattern(applicationContext.getInitParams()));
|
||||
Set<URL> finalSet = new HashSet<URL>();
|
||||
|
||||
Set<String> definitions = getTilesDefinitions(applicationContext.getInitParams());
|
||||
for (String definition : definitions) {
|
||||
finalSet.addAll(applicationContext.getResources(definition));
|
||||
}
|
||||
|
||||
return URLUtil.getBaseTilesDefinitionURLs(finalSet);
|
||||
} catch (IOException e) {
|
||||
@@ -209,11 +217,14 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory {
|
||||
}
|
||||
}
|
||||
|
||||
protected String getTilesDefinitionPattern(Map<String, String> params) {
|
||||
protected Set<String> getTilesDefinitions(Map<String, String> params) {
|
||||
if (params.containsKey(DefinitionsFactory.DEFINITIONS_CONFIG)) {
|
||||
return params.get(DefinitionsFactory.DEFINITIONS_CONFIG);
|
||||
return TextParseUtil.commaDelimitedStringToSet(params.get(DefinitionsFactory.DEFINITIONS_CONFIG));
|
||||
}
|
||||
return TILES_DEFAULT_PATTERN;
|
||||
if (params.containsKey(BasicTilesContainer.DEFINITIONS_CONFIG)) {
|
||||
return TextParseUtil.commaDelimitedStringToSet(params.get(BasicTilesContainer.DEFINITIONS_CONFIG));
|
||||
}
|
||||
return TextParseUtil.commaDelimitedStringToSet(TILES_DEFAULT_PATTERN);
|
||||
}
|
||||
|
||||
protected ELAttributeEvaluator createELEvaluator(TilesApplicationContext applicationContext) {
|
||||
|
||||
@@ -22,7 +22,10 @@ package org.apache.struts2.tiles;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
import org.apache.tiles.TilesApplicationContext;
|
||||
import org.apache.tiles.definition.DefinitionsFactory;
|
||||
import org.apache.tiles.factory.AbstractTilesContainerFactory;
|
||||
import org.apache.tiles.impl.BasicTilesContainer;
|
||||
import org.apache.tiles.servlet.context.ServletTilesApplicationContext;
|
||||
import org.apache.tiles.startup.AbstractTilesInitializer;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
@@ -33,8 +36,20 @@ public class StrutsTilesInitializer extends AbstractTilesInitializer {
|
||||
|
||||
@Override
|
||||
protected TilesApplicationContext createTilesApplicationContext(TilesApplicationContext preliminaryContext) {
|
||||
LOG.debug("Initializing Tiles wildcard support ...");
|
||||
return new StrutsWildcardServletTilesApplicationContext((ServletContext) preliminaryContext.getContext());
|
||||
ServletContext servletContext = (ServletContext) preliminaryContext.getContext();
|
||||
|
||||
if (isStaticDefinition(servletContext)) {
|
||||
LOG.trace("Found definitions config in web.xml, using standard Servlet support ....");
|
||||
return new ServletTilesApplicationContext(servletContext);
|
||||
} else {
|
||||
LOG.trace("Initializing Struts Tiles wildcard support ...");
|
||||
return new StrutsWildcardServletTilesApplicationContext(servletContext);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isStaticDefinition(ServletContext servletContext) {
|
||||
return servletContext.getInitParameter(DefinitionsFactory.DEFINITIONS_CONFIG) != null ||
|
||||
servletContext.getInitParameter(BasicTilesContainer.DEFINITIONS_CONFIG) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-2
@@ -50,8 +50,12 @@ public class StrutsWildcardServletTilesApplicationContext extends ServletTilesAp
|
||||
|
||||
for (Object path : context.getResourcePaths("/")) {
|
||||
try {
|
||||
URL url = new File(context.getRealPath(String.valueOf(path))).toURI().toURL();
|
||||
urls.add(url);
|
||||
String realPath = context.getRealPath(String.valueOf(path));
|
||||
|
||||
if (realPath != null) {
|
||||
URL url = new File(realPath).toURI().toURL();
|
||||
urls.add(url);
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
throw new ConfigurationException(e);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-tiles3-plugin</artifactId>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Struts 2</name>
|
||||
<url>http://struts.apache.org/</url>
|
||||
@@ -31,7 +31,7 @@
|
||||
<connection>scm:git:git://git.apache.org/struts.git</connection>
|
||||
<developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/struts.git</developerConnection>
|
||||
<url>http://git.apache.org/struts.git</url>
|
||||
<tag>STRUTS_2_3_28</tag>
|
||||
<tag>STRUTS_2_3_30</tag>
|
||||
</scm>
|
||||
|
||||
<issueManagement>
|
||||
@@ -86,7 +86,7 @@
|
||||
<properties>
|
||||
<currentVersion>${project.version}</currentVersion>
|
||||
<struts2.springPlatformVersion>3.0.5.RELEASE</struts2.springPlatformVersion>
|
||||
<ognl.version>3.0.13</ognl.version>
|
||||
<ognl.version>3.0.19</ognl.version>
|
||||
<asm.version>3.3</asm.version>
|
||||
<asm5.version>5.0.2</asm5.version>
|
||||
<tiles.version>2.2.2</tiles.version>
|
||||
@@ -759,12 +759,12 @@
|
||||
<dependency>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<version>3.1</version>
|
||||
<version>3.2.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>1.3.1</version>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>2.3.28</version>
|
||||
<version>2.3.30</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.apache.struts.xwork</groupId>
|
||||
|
||||
@@ -178,10 +178,6 @@ public class ActionSupport implements Action, Validateable, ValidationAware, Tex
|
||||
return INPUT;
|
||||
}
|
||||
|
||||
public String doDefault() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* A default implementation that does nothing an returns "success".
|
||||
* <p/>
|
||||
|
||||
@@ -427,13 +427,13 @@ public class DefaultActionInvocation implements ActionInvocation {
|
||||
|
||||
Object methodResult;
|
||||
try {
|
||||
methodResult = ognlUtil.getValue(methodName + "()", getStack().getContext(), action);
|
||||
methodResult = ognlUtil.callMethod(methodName + "()", getStack().getContext(), action);
|
||||
} catch (MethodFailedException e) {
|
||||
// if reason is missing method, try find version with "do" prefix
|
||||
if (e.getReason() instanceof NoSuchMethodException) {
|
||||
try {
|
||||
String altMethodName = "do" + methodName.substring(0, 1).toUpperCase() + methodName.substring(1) + "()";
|
||||
methodResult = ognlUtil.getValue(altMethodName, getStack().getContext(), action);
|
||||
methodResult = ognlUtil.callMethod(altMethodName, getStack().getContext(), action);
|
||||
} catch (MethodFailedException e1) {
|
||||
// if still method doesn't exist, try checking UnknownHandlers
|
||||
if (e1.getReason() instanceof NoSuchMethodException) {
|
||||
|
||||
@@ -288,7 +288,10 @@ public class OgnlUtil {
|
||||
compileAndExecute(name, context, new OgnlTask<Void>() {
|
||||
public Void execute(Object tree) throws OgnlException {
|
||||
if (isEvalExpression(tree, context)) {
|
||||
throw new OgnlException("Eval expression cannot be used as parameter name");
|
||||
throw new OgnlException("Eval expression/chained expressions cannot be used as parameter name");
|
||||
}
|
||||
if (isArithmeticExpression(tree, context)) {
|
||||
throw new OgnlException("Arithmetic expressions cannot be used as parameter name");
|
||||
}
|
||||
Ognl.setValue(tree, context, root, value);
|
||||
return null;
|
||||
@@ -304,7 +307,33 @@ public class OgnlUtil {
|
||||
if (context!=null && context instanceof OgnlContext) {
|
||||
ognlContext = (OgnlContext) context;
|
||||
}
|
||||
return node.isEvalChain(ognlContext);
|
||||
return node.isEvalChain(ognlContext) || node.isSequence(ognlContext);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isArithmeticExpression(Object tree, Map<String, Object> context) throws OgnlException {
|
||||
if (tree instanceof SimpleNode) {
|
||||
SimpleNode node = (SimpleNode) tree;
|
||||
OgnlContext ognlContext = null;
|
||||
|
||||
if (context!=null && context instanceof OgnlContext) {
|
||||
ognlContext = (OgnlContext) context;
|
||||
}
|
||||
return node.isOperation(ognlContext);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isSimpleMethod(Object tree, Map<String, Object> context) throws OgnlException {
|
||||
if (tree instanceof SimpleNode) {
|
||||
SimpleNode node = (SimpleNode) tree;
|
||||
OgnlContext ognlContext = null;
|
||||
|
||||
if (context!=null && context instanceof OgnlContext) {
|
||||
ognlContext = (OgnlContext) context;
|
||||
}
|
||||
return node.isSimpleMethod(ognlContext) && !node.isChain(ognlContext);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -317,6 +346,14 @@ public class OgnlUtil {
|
||||
});
|
||||
}
|
||||
|
||||
public Object callMethod(final String name, final Map<String, Object> context, final Object root) throws OgnlException {
|
||||
return compileAndExecuteMethod(name, context, new OgnlTask<Object>() {
|
||||
public Object execute(Object tree) throws OgnlException {
|
||||
return Ognl.getValue(tree, context, root);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Object getValue(final String name, final Map<String, Object> context, final Object root, final Class resultType) throws OgnlException {
|
||||
return compileAndExecute(name, context, new OgnlTask<Object>() {
|
||||
public Object execute(Object tree) throws OgnlException {
|
||||
@@ -351,6 +388,27 @@ public class OgnlUtil {
|
||||
return exec;
|
||||
}
|
||||
|
||||
private <T> Object compileAndExecuteMethod(String expression, Map<String, Object> context, OgnlTask<T> task) throws OgnlException {
|
||||
Object tree;
|
||||
if (enableExpressionCache) {
|
||||
tree = expressions.get(expression);
|
||||
if (tree == null) {
|
||||
tree = Ognl.parseExpression(expression);
|
||||
checkSimpleMethod(tree, context);
|
||||
}
|
||||
} else {
|
||||
tree = Ognl.parseExpression(expression);
|
||||
checkSimpleMethod(tree, context);
|
||||
}
|
||||
|
||||
final T exec = task.execute(tree);
|
||||
// if cache is enabled and it's a valid expression, puts it in
|
||||
if(enableExpressionCache) {
|
||||
expressions.putIfAbsent(expression, tree);
|
||||
}
|
||||
return exec;
|
||||
}
|
||||
|
||||
public Object compile(String expression, Map<String, Object> context) throws OgnlException {
|
||||
return compileAndExecute(expression,context,new OgnlTask<Object>() {
|
||||
public Object execute(Object tree) throws OgnlException {
|
||||
@@ -361,7 +419,13 @@ public class OgnlUtil {
|
||||
|
||||
private void checkEnableEvalExpression(Object tree, Map<String, Object> context) throws OgnlException {
|
||||
if (!enableEvalExpression && isEvalExpression(tree, context)) {
|
||||
throw new OgnlException("Eval expressions has been disabled!");
|
||||
throw new OgnlException("Eval expressions/chained expressions have been disabled!");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkSimpleMethod(Object tree, Map<String, Object> context) throws OgnlException {
|
||||
if (!isSimpleMethod(tree, context)) {
|
||||
throw new OgnlException("It isn't a simple method which can be called!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ package com.opensymphony.xwork2.validator.validators;
|
||||
* The regular expression used to validate that the string is an email address is:
|
||||
*
|
||||
* <pre>
|
||||
* \\b^['_a-z0-9-\\+]+(\\.['_a-z0-9-\\+]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*\\.([a-z]{2}|aero|arpa|asia|biz|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|nato|net|org|pro|tel|travel|xxx)$\\b
|
||||
* \\b^['_a-z0-9-\\+]+(\\.['_a-z0-9-\\+]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*\\.([a-z]{2}|aero|arpa|asia|biz|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|nato|net|org|pro|tel|travel|xxx|tech|cat)$\\b
|
||||
* </pre>
|
||||
*
|
||||
* You can also specify expression, caseSensitive and trim params as a OGNL expression, see the example below.
|
||||
@@ -80,7 +80,7 @@ public class EmailValidator extends RegexFieldValidator {
|
||||
|
||||
// see XW-371
|
||||
public static final String EMAIL_ADDRESS_PATTERN =
|
||||
"\\b^['_a-z0-9-\\+]+(\\.['_a-z0-9-\\+]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*\\.([a-z]{2}|aero|arpa|asia|biz|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|nato|net|org|pro|tel|travel|xxx|tech)$\\b";
|
||||
"\\b^['_a-z0-9-\\+]+(\\.['_a-z0-9-\\+]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*\\.([a-z]{2}|aero|arpa|asia|biz|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|nato|net|org|pro|tel|travel|xxx|tech|cat)$\\b";
|
||||
|
||||
public EmailValidator() {
|
||||
setRegex(EMAIL_ADDRESS_PATTERN);
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ public class URLValidator extends FieldValidatorSupport {
|
||||
"|((\\d|[1-9]\\d|1\\d{2}|2[0-4][0-9]|25[0-5])\\.){3}" +
|
||||
"(\\d|[1-9]\\d|1\\d{2}|2[0-4][0-9]|25[0-5])" +
|
||||
")(:\\d+)?" +
|
||||
")(((\\/+([a-z0-9$_\\.\\+!\\*\\'\\(\\),;:@&=-]|%[0-9a-f]{2})*)*" +
|
||||
")(((\\/{0,1}([a-z0-9$_\\.\\+!\\*\\'\\(\\),;:@&=-]|%[0-9a-f]{2})*)*" +
|
||||
"(\\?([a-z0-9$_\\.\\+!\\*\\'\\(\\),;:@&=-]|%[0-9a-f]{2})*)" +
|
||||
"?)?)?" +
|
||||
"(#([a-z0-9$_\\.\\+!\\*\\'\\(\\),;:@&=-]|%[0-9a-f]{2})*)?" +
|
||||
|
||||
@@ -68,7 +68,6 @@ public class ActionSupportTest extends XWorkTestCase {
|
||||
}
|
||||
|
||||
assertEquals(Action.INPUT, as.input());
|
||||
assertEquals(Action.SUCCESS, as.doDefault());
|
||||
assertEquals(Action.SUCCESS, as.execute());
|
||||
try {
|
||||
as.clone();
|
||||
@@ -169,7 +168,7 @@ public class ActionSupportTest extends XWorkTestCase {
|
||||
ActionContext.getContext().setLocale(new Locale("da"));
|
||||
MyActionSupport mas = new MyActionSupport();
|
||||
|
||||
assertEquals("santa", mas.doDefault());
|
||||
assertEquals("santa", mas.execute());
|
||||
assertNotNull(mas.getTexts());
|
||||
|
||||
assertEquals(false, mas.hasActionMessages());
|
||||
@@ -343,7 +342,7 @@ public class ActionSupportTest extends XWorkTestCase {
|
||||
private Double val;
|
||||
|
||||
@Override
|
||||
public String doDefault() throws Exception {
|
||||
public String execute() throws Exception {
|
||||
return "santa";
|
||||
}
|
||||
|
||||
|
||||
@@ -750,6 +750,36 @@ public class OgnlUtilTest extends XWorkTestCase {
|
||||
assertEquals(expected.getMessage(), "Method \"getRuntime\" failed for object class java.lang.Runtime");
|
||||
}
|
||||
|
||||
public void testBlockSequenceOfExpressions() throws Exception {
|
||||
Foo foo = new Foo();
|
||||
|
||||
Exception expected = null;
|
||||
try {
|
||||
ognlUtil.setValue("#booScope=@myclass@DEFAULT_SCOPE,#bootScope.init()", ognlUtil.createDefaultContext(foo), foo, true);
|
||||
fail();
|
||||
} catch (OgnlException e) {
|
||||
expected = e;
|
||||
}
|
||||
assertNotNull(expected);
|
||||
assertSame(OgnlException.class, expected.getClass());
|
||||
assertEquals(expected.getMessage(), "Eval expressions/chained expressions have been disabled!");
|
||||
}
|
||||
|
||||
public void testCallMethod() throws Exception {
|
||||
Foo foo = new Foo();
|
||||
|
||||
Exception expected = null;
|
||||
try {
|
||||
ognlUtil.callMethod("#booScope=@myclass@DEFAULT_SCOPE,#bootScope.init()", ognlUtil.createDefaultContext(foo), foo);
|
||||
fail();
|
||||
} catch (OgnlException e) {
|
||||
expected = e;
|
||||
}
|
||||
assertNotNull(expected);
|
||||
assertSame(OgnlException.class, expected.getClass());
|
||||
assertEquals(expected.getMessage(), "It isn't a simple method which can be called!");
|
||||
}
|
||||
|
||||
public static class Email {
|
||||
String address;
|
||||
|
||||
|
||||
+4
-28
@@ -119,24 +119,6 @@ public class SecurityMemberAccessTest extends TestCase {
|
||||
assertTrue("fooLogic() from FooInterface isn't accessible!!!", accessible);
|
||||
}
|
||||
|
||||
public void testMiddleOfInheritanceExclusion2() throws Exception {
|
||||
// given
|
||||
SecurityMemberAccess sma = new SecurityMemberAccess(false);
|
||||
|
||||
String propertyName = "barLogic";
|
||||
Member member = BarInterface.class.getMethod(propertyName);
|
||||
|
||||
Set<Class<?>> excluded = new HashSet<Class<?>>();
|
||||
excluded.add(BarInterface.class);
|
||||
sma.setExcludedClasses(excluded);
|
||||
|
||||
// when
|
||||
boolean accessible = sma.isAccessible(context, target, member, propertyName);
|
||||
|
||||
// then
|
||||
assertFalse("barLogic() from BarInterface is accessible!!!", accessible);
|
||||
}
|
||||
|
||||
public void testMiddleOfInheritanceExclusion3() throws Exception {
|
||||
// given
|
||||
SecurityMemberAccess sma = new SecurityMemberAccess(false);
|
||||
@@ -144,12 +126,6 @@ public class SecurityMemberAccessTest extends TestCase {
|
||||
String propertyName = "barLogic";
|
||||
Member member = BarInterface.class.getMethod(propertyName);
|
||||
|
||||
/*
|
||||
Set<Class<?>> excluded = new HashSet<Class<?>>();
|
||||
excluded.add(BarInterface.class);
|
||||
sma.setExcludedClasses(excluded);
|
||||
*/
|
||||
|
||||
// when
|
||||
boolean accessible = sma.isAccessible(context, target, member, propertyName);
|
||||
|
||||
@@ -256,7 +232,7 @@ public class SecurityMemberAccessTest extends TestCase {
|
||||
public void testAccessStatic() throws Exception {
|
||||
// given
|
||||
SecurityMemberAccess sma = new SecurityMemberAccess(true);
|
||||
sma.setExcludedClasses(new HashSet<Class<?>>(Arrays.<Class<?>>asList(Class.class)));
|
||||
sma.setExcludedClasses(new HashSet<Class<?>>(Collections.singletonList(Class.class)));
|
||||
|
||||
// when
|
||||
Member method = StaticTester.class.getMethod("sayHello");
|
||||
@@ -269,7 +245,7 @@ public class SecurityMemberAccessTest extends TestCase {
|
||||
public void testBlockStaticAccess() throws Exception {
|
||||
// given
|
||||
SecurityMemberAccess sma = new SecurityMemberAccess(false);
|
||||
sma.setExcludedClasses(new HashSet<Class<?>>(Arrays.<Class<?>>asList(Class.class)));
|
||||
sma.setExcludedClasses(new HashSet<Class<?>>(Collections.singletonList(Class.class)));
|
||||
|
||||
// when
|
||||
Member method = StaticTester.class.getMethod("sayHello");
|
||||
@@ -282,7 +258,7 @@ public class SecurityMemberAccessTest extends TestCase {
|
||||
public void testBlockStaticAccessIfClassIsExcluded() throws Exception {
|
||||
// given
|
||||
SecurityMemberAccess sma = new SecurityMemberAccess(false);
|
||||
sma.setExcludedClasses(new HashSet<Class<?>>(Arrays.<Class<?>>asList(Class.class)));
|
||||
sma.setExcludedClasses(new HashSet<Class<?>>(Collections.singletonList(Class.class)));
|
||||
|
||||
// when
|
||||
Member method = Class.class.getMethod("getClassLoader");
|
||||
@@ -295,7 +271,7 @@ public class SecurityMemberAccessTest extends TestCase {
|
||||
public void testAllowStaticAccessIfClassIsNotExcluded() throws Exception {
|
||||
// given
|
||||
SecurityMemberAccess sma = new SecurityMemberAccess(true);
|
||||
sma.setExcludedClasses(new HashSet<Class<?>>(Arrays.<Class<?>>asList(ClassLoader.class)));
|
||||
sma.setExcludedClasses(new HashSet<Class<?>>(Collections.singletonList(ClassLoader.class)));
|
||||
|
||||
// when
|
||||
Member method = Class.class.getMethod("getClassLoader");
|
||||
|
||||
@@ -44,6 +44,7 @@ public class EmailValidatorTest extends XWorkTestCase {
|
||||
assertTrue(verifyEmailValidity("tmj'ee@yahoo.com"));
|
||||
assertTrue(verifyEmailValidity("ferda+mravenec@yahoo.com"));
|
||||
assertTrue(verifyEmailValidity("Ferda+Mravenec@yaHoo.CoM"));
|
||||
assertTrue(verifyEmailValidity("Ferda+Mravenec@yaHoo.cat"));
|
||||
|
||||
assertFalse(verifyEmailValidity("tm_jee#marry@yahoo.co.uk"));
|
||||
assertFalse(verifyEmailValidity("tm_jee@ yahoo.co.uk"));
|
||||
|
||||
@@ -139,6 +139,7 @@ public class URLValidatorTest extends XWorkTestCase {
|
||||
assertFalse(pattern.matcher("").matches());
|
||||
assertFalse(pattern.matcher(" ").matches());
|
||||
assertFalse(pattern.matcher("no url").matches());
|
||||
assertFalse(pattern.matcher("http://example.com////////////////////////////////////////////////////////////////////////////////////??").matches());
|
||||
|
||||
assertTrue(pattern.matcher("http://www.opensymphony.com").matches());
|
||||
assertTrue(pattern.matcher("https://www.opensymphony.com").matches());
|
||||
|
||||
Reference in New Issue
Block a user