mirror of
https://github.com/apache/struts.git
synced 2026-08-08 16:16:58 +00:00
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1ed29d508f | |||
| 3523064939 | |||
| 54dff362f5 | |||
| b12864dd38 | |||
| de90290354 | |||
| ba0563183b | |||
| b348fc552c | |||
| 81371e09c5 | |||
| 431e50e922 | |||
| 156db8e5df | |||
| 6f5ddca471 | |||
| cc0d52f216 | |||
| 23e0181328 | |||
| 030ffa3354 | |||
| 8e67b9144a | |||
| 77017cd677 | |||
| 7d8c3598ef | |||
| 83bb64f4c2 | |||
| ae2840f183 | |||
| e8b48f8bb4 | |||
| 3243448084 |
+1
-1
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-blank</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-jboss-blank</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</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.30</version>
|
||||
<version>2.3.32</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.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-portlet</artifactId>
|
||||
|
||||
@@ -26,12 +26,12 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-rest-showcase</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</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.30</version>
|
||||
<version>2.3.32</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.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-archetypes</artifactId>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-archetypes</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-archetypes</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-archetypes</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-archetypes</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-archetypes</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-archetypes</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-archetypes</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</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.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-assembly</artifactId>
|
||||
|
||||
+3
-3
@@ -10,7 +10,7 @@
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-bom</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Struts 2 Bill of Materials</name>
|
||||
@@ -25,7 +25,7 @@
|
||||
</licenses>
|
||||
|
||||
<properties>
|
||||
<struts-version.version>2.3.30</struts-version.version>
|
||||
<struts-version.version>2.3.32</struts-version.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
@@ -197,6 +197,6 @@
|
||||
</dependencyManagement>
|
||||
|
||||
<scm>
|
||||
<tag>STRUTS_2_3_30</tag>
|
||||
<tag>STRUTS_2_3_32</tag>
|
||||
</scm>
|
||||
</project>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-osgi-bundles</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</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.30</version>
|
||||
<version>2.3.32</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.30</version>
|
||||
<version>2.3.32</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.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
<artifactId>struts2-core</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -272,6 +272,13 @@ public final class StrutsConstants {
|
||||
|
||||
/** actions names' whitelist **/
|
||||
public static final String STRUTS_ALLOWED_ACTION_NAMES = "struts.allowed.action.names";
|
||||
/** default action name to use when action didn't match the whitelist **/
|
||||
public static final String STRUTS_DEFAULT_ACTION_NAME = "struts.default.action.name";
|
||||
|
||||
/** methods names' whitelist **/
|
||||
public static final String STRUTS_ALLOWED_METHOD_NAMES = "struts.allowed.method.names";
|
||||
/** default method name to use when method didn't match the whitelist **/
|
||||
public static final String STRUTS_DEFAULT_METHOD_NAME = "struts.default.method.name";
|
||||
|
||||
/** enables action: prefix **/
|
||||
public static final String STRUTS_MAPPER_ACTION_PREFIX_ENABLED = "struts.mapper.action.prefix.enabled";
|
||||
|
||||
@@ -22,6 +22,8 @@ package org.apache.struts2.dispatcher;
|
||||
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.ClassLoaderUtil;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
@@ -39,6 +41,7 @@ import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.LinkedList;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
/**
|
||||
@@ -93,6 +96,7 @@ public class DefaultStaticContentLoader implements StaticContentLoader {
|
||||
*/
|
||||
protected String encoding;
|
||||
|
||||
protected boolean devMode;
|
||||
|
||||
/**
|
||||
* Modify state of StrutsConstants.STRUTS_SERVE_STATIC_CONTENT setting.
|
||||
@@ -101,29 +105,34 @@ public class DefaultStaticContentLoader implements StaticContentLoader {
|
||||
* New setting
|
||||
*/
|
||||
@Inject(StrutsConstants.STRUTS_SERVE_STATIC_CONTENT)
|
||||
public void setServeStaticContent(String val) {
|
||||
serveStatic = "true".equals(val);
|
||||
public void setServeStaticContent(String serveStaticContent) {
|
||||
this.serveStatic = BooleanUtils.toBoolean(serveStaticContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify state of StrutsConstants.STRUTS_SERVE_STATIC_BROWSER_CACHE
|
||||
* setting.
|
||||
*
|
||||
* @param val
|
||||
* @param serveStaticBrowserCache
|
||||
* New setting
|
||||
*/
|
||||
@Inject(StrutsConstants.STRUTS_SERVE_STATIC_BROWSER_CACHE)
|
||||
public void setServeStaticBrowserCache(String val) {
|
||||
serveStaticBrowserCache = "true".equals(val);
|
||||
public void setServeStaticBrowserCache(String serveStaticBrowserCache) {
|
||||
this.serveStaticBrowserCache = BooleanUtils.toBoolean(serveStaticBrowserCache);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify state of StrutsConstants.STRUTS_I18N_ENCODING setting.
|
||||
* @param val New setting
|
||||
* @param encoding New setting
|
||||
*/
|
||||
@Inject(StrutsConstants.STRUTS_I18N_ENCODING)
|
||||
public void setEncoding(String val) {
|
||||
encoding = val;
|
||||
public void setEncoding(String encoding) {
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
@Inject(StrutsConstants.STRUTS_DEVMODE)
|
||||
public void setDevMode(String devMode) {
|
||||
this.devMode = Boolean.parseBoolean(devMode);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -141,7 +150,16 @@ public class DefaultStaticContentLoader implements StaticContentLoader {
|
||||
}
|
||||
|
||||
protected String getAdditionalPackages() {
|
||||
return "org.apache.struts2.static template org.apache.struts2.interceptor.debugging static";
|
||||
List<String> packages = new LinkedList<String>();
|
||||
packages.add("org.apache.struts2.static");
|
||||
packages.add("template");
|
||||
packages.add("static");
|
||||
|
||||
if (devMode) {
|
||||
packages.add("org.apache.struts2.interceptor.debugging");
|
||||
}
|
||||
|
||||
return StringUtils.join(packages.iterator(), ' ');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -273,7 +291,7 @@ public class DefaultStaticContentLoader implements StaticContentLoader {
|
||||
* @param name resource name
|
||||
* @param packagePrefix The package prefix to use to locate the resource
|
||||
* @return full path
|
||||
* @throws UnsupportedEncodingException
|
||||
* @throws UnsupportedEncodingException If there is a encoding problem
|
||||
*/
|
||||
protected String buildPath(String name, String packagePrefix) throws UnsupportedEncodingException {
|
||||
String resourcePath;
|
||||
|
||||
@@ -211,7 +211,11 @@ public class Dispatcher {
|
||||
*/
|
||||
@Inject(StrutsConstants.STRUTS_DEVMODE)
|
||||
public void setDevMode(String mode) {
|
||||
devMode = "true".equals(mode);
|
||||
devMode = Boolean.parseBoolean(mode);
|
||||
}
|
||||
|
||||
public boolean isDevMode() {
|
||||
return devMode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -265,6 +269,10 @@ public class Dispatcher {
|
||||
this.handleException = Boolean.parseBoolean(handleException);
|
||||
}
|
||||
|
||||
public boolean isHandleException() {
|
||||
return handleException;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setDispatcherErrorHandler(DispatcherErrorHandler errorHandler) {
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
@@ -121,6 +121,11 @@ public class DefaultActionMapper implements ActionMapper {
|
||||
protected boolean alwaysSelectFullNamespace = false;
|
||||
protected PrefixTrie prefixTrie = null;
|
||||
protected Pattern allowedActionNames = Pattern.compile("[a-zA-Z0-9._!/\\-]*");
|
||||
protected String defaultActionName = "index";
|
||||
|
||||
protected Pattern allowedMethodNames = Pattern.compile("[a-zA-Z_]*[0-9]*");
|
||||
protected String defaultMethodName = "execute";
|
||||
|
||||
private boolean allowActionPrefix = false;
|
||||
private boolean allowActionCrossNamespaceAccess = false;
|
||||
|
||||
@@ -137,7 +142,7 @@ public class DefaultActionMapper implements ActionMapper {
|
||||
put(METHOD_PREFIX, new ParameterAction() {
|
||||
public void execute(String key, ActionMapping mapping) {
|
||||
if (allowDynamicMethodCalls) {
|
||||
mapping.setMethod(cleanupActionName(key.substring(METHOD_PREFIX.length())));
|
||||
mapping.setMethod(cleanupMethodName(key.substring(METHOD_PREFIX.length())));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -149,7 +154,7 @@ public class DefaultActionMapper implements ActionMapper {
|
||||
if (allowDynamicMethodCalls) {
|
||||
int bang = name.indexOf('!');
|
||||
if (bang != -1) {
|
||||
String method = cleanupActionName(name.substring(bang + 1));
|
||||
String method = cleanupMethodName(name.substring(bang + 1));
|
||||
mapping.setMethod(method);
|
||||
name = name.substring(0, bang);
|
||||
}
|
||||
@@ -205,6 +210,21 @@ public class DefaultActionMapper implements ActionMapper {
|
||||
this.allowedActionNames = Pattern.compile(allowedActionNames);
|
||||
}
|
||||
|
||||
@Inject(value = StrutsConstants.STRUTS_DEFAULT_ACTION_NAME, required = false)
|
||||
public void setDefaultActionName(String defaultActionName) {
|
||||
this.defaultActionName = defaultActionName;
|
||||
}
|
||||
|
||||
@Inject(value = StrutsConstants.STRUTS_ALLOWED_METHOD_NAMES, required = false)
|
||||
public void setAllowedMethodNames(String allowedMethodNames) {
|
||||
this.allowedMethodNames = Pattern.compile(allowedMethodNames);
|
||||
}
|
||||
|
||||
@Inject(value = StrutsConstants.STRUTS_DEFAULT_METHOD_NAME, required = false)
|
||||
public void setDefaultMethodName(String defaultMethodName) {
|
||||
this.defaultMethodName = defaultMethodName;
|
||||
}
|
||||
|
||||
@Inject(value = StrutsConstants.STRUTS_MAPPER_ACTION_PREFIX_ENABLED)
|
||||
public void setAllowActionPrefix(String allowActionPrefix) {
|
||||
this.allowActionPrefix = "true".equalsIgnoreCase(allowActionPrefix);
|
||||
@@ -376,7 +396,7 @@ public class DefaultActionMapper implements ActionMapper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans up action name from suspicious characters
|
||||
* Checks action name against allowed pattern if not matched returns default action name
|
||||
*
|
||||
* @param rawActionName action name extracted from URI
|
||||
* @return safe action name
|
||||
@@ -385,7 +405,23 @@ public class DefaultActionMapper implements ActionMapper {
|
||||
if (allowedActionNames.matcher(rawActionName).matches()) {
|
||||
return rawActionName;
|
||||
} else {
|
||||
throw new StrutsException("Action [" + rawActionName + "] does not match allowed action names pattern [" + allowedActionNames + "]!");
|
||||
LOG.warn("{} did not match allowed action names {} - default action {} will be used!", rawActionName, allowedActionNames, defaultActionName);
|
||||
return defaultActionName;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks method name (when DMI is enabled) against allowed pattern if not matched returns default action name
|
||||
*
|
||||
* @param rawMethodName method name extracted from URI
|
||||
* @return safe method name
|
||||
*/
|
||||
protected String cleanupMethodName(final String rawMethodName) {
|
||||
if (allowedMethodNames.matcher(rawMethodName).matches()) {
|
||||
return rawMethodName;
|
||||
} else {
|
||||
LOG.warn("{} did not match allowed method names {} - default method {} will be used!", rawMethodName, allowedMethodNames, defaultMethodName);
|
||||
return defaultMethodName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -120,7 +120,11 @@ public class JakartaMultiPartRequest implements MultiPartRequest {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Preparing error message for key: [#0]", errorKey);
|
||||
}
|
||||
return LocalizedTextUtil.findText(this.getClass(), errorKey, defaultLocale, e.getMessage(), args);
|
||||
if (LocalizedTextUtil.findText(this.getClass(), errorKey, defaultLocale, null, new Object[0]) == null) {
|
||||
return LocalizedTextUtil.findText(this.getClass(), "struts.messages.error.uploading", defaultLocale, null, new Object[] { e.getMessage() });
|
||||
} else {
|
||||
return LocalizedTextUtil.findText(this.getClass(), errorKey, defaultLocale, null, args);
|
||||
}
|
||||
}
|
||||
|
||||
protected void processUpload(HttpServletRequest request, String saveDir) throws FileUploadException, UnsupportedEncodingException {
|
||||
|
||||
+5
-1
@@ -539,7 +539,11 @@ public class JakartaStreamMultiPartRequest implements MultiPartRequest {
|
||||
String errorKey = "struts.message.upload.error." + e.getClass().getSimpleName();
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Preparing error message for key: [#0]", errorKey);
|
||||
return LocalizedTextUtil.findText(this.getClass(), errorKey, defaultLocale, e.getMessage(), args);
|
||||
if (LocalizedTextUtil.findText(this.getClass(), errorKey, defaultLocale, null, new Object[0]) == null) {
|
||||
return LocalizedTextUtil.findText(this.getClass(), "struts.messages.error.uploading", defaultLocale, null, new Object[] { e.getMessage() });
|
||||
} else {
|
||||
return LocalizedTextUtil.findText(this.getClass(), errorKey, defaultLocale, null, args);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+5
-1
@@ -108,7 +108,11 @@ public class MultiPartRequestWrapper extends StrutsRequestWrapper {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Preparing error message for key: [#0]", errorKey);
|
||||
}
|
||||
return LocalizedTextUtil.findText(this.getClass(), errorKey, defaultLocale, e.getMessage(), args);
|
||||
if (LocalizedTextUtil.findText(this.getClass(), errorKey, getLocale(), null, new Object[0]) == null) {
|
||||
return LocalizedTextUtil.findText(this.getClass(), "struts.messages.error.uploading", defaultLocale, null, new Object[] { e.getMessage() });
|
||||
} else {
|
||||
return LocalizedTextUtil.findText(this.getClass(), errorKey, defaultLocale, null, args);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -168,7 +168,9 @@ public class PrepareOperations {
|
||||
request.setAttribute(STRUTS_ACTION_MAPPING_KEY, mapping);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
dispatcher.sendError(request, response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex);
|
||||
if (dispatcher.isHandleException() || dispatcher.isDevMode()) {
|
||||
dispatcher.sendError(request, response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,11 +44,11 @@ public class ComponentUtils {
|
||||
* @return true if it is an expression
|
||||
*/
|
||||
public static boolean isExpression(String expr) {
|
||||
return expr.startsWith("%{") && expr.endsWith("}");
|
||||
return expr != null && expr.startsWith("%{") && expr.endsWith("}");
|
||||
}
|
||||
|
||||
public static boolean containsExpression(String expr) {
|
||||
return expr.contains("%{") && expr.contains("}");
|
||||
return expr != null && expr.contains("%{") && expr.contains("}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,4 +19,16 @@ public class URLDecoderUtil {
|
||||
return UDecoder.URLDecode(sequence, charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes a <code>x-www-form-urlencoded</code> string.
|
||||
* @param sequence the String to decode
|
||||
* @param charset The name of a supported character encoding.
|
||||
* @param isQueryString whether input is a query string. If <code>true</code> other decoding rules apply.
|
||||
* @return the newly decoded <code>String</code>
|
||||
* @exception IllegalArgumentException If the encoding is not valid
|
||||
*/
|
||||
public static String decode(String sequence, String charset, boolean isQueryString) {
|
||||
return UDecoder.URLDecode(sequence, charset, isQueryString);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,18 @@ package org.apache.struts2.views.util;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
@@ -179,9 +191,9 @@ public class DefaultUrlHelper implements UrlHelper {
|
||||
|
||||
//if the action was not explicitly set grab the params from the request
|
||||
if (escapeAmp) {
|
||||
buildParametersString(params, link, AMP);
|
||||
buildParametersString(params, link, AMP, true);
|
||||
} else {
|
||||
buildParametersString(params, link, "&");
|
||||
buildParametersString(params, link, "&", true);
|
||||
}
|
||||
|
||||
String result = link.toString();
|
||||
@@ -202,6 +214,10 @@ public class DefaultUrlHelper implements UrlHelper {
|
||||
}
|
||||
|
||||
public void buildParametersString(Map<String, Object> params, StringBuilder link, String paramSeparator) {
|
||||
buildParametersString(params, link, paramSeparator, true);
|
||||
}
|
||||
|
||||
public void buildParametersString(Map<String, Object> params, StringBuilder link, String paramSeparator, boolean encode) {
|
||||
if ((params != null) && (params.size() > 0)) {
|
||||
if (!link.toString().contains("?")) {
|
||||
link.append("?");
|
||||
@@ -219,7 +235,7 @@ public class DefaultUrlHelper implements UrlHelper {
|
||||
if (value instanceof Iterable) {
|
||||
for (Iterator iterator = ((Iterable) value).iterator(); iterator.hasNext();) {
|
||||
Object paramValue = iterator.next();
|
||||
link.append(buildParameterSubstring(name, paramValue != null ? paramValue.toString() : StringUtils.EMPTY));
|
||||
link.append(buildParameterSubstring(name, paramValue != null ? paramValue.toString() : StringUtils.EMPTY, encode));
|
||||
|
||||
if (iterator.hasNext()) {
|
||||
link.append(paramSeparator);
|
||||
@@ -229,14 +245,14 @@ public class DefaultUrlHelper implements UrlHelper {
|
||||
Object[] array = (Object[]) value;
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
Object paramValue = array[i];
|
||||
link.append(buildParameterSubstring(name, paramValue != null ? paramValue.toString() : StringUtils.EMPTY));
|
||||
link.append(buildParameterSubstring(name, paramValue != null ? paramValue.toString() : StringUtils.EMPTY, encode));
|
||||
|
||||
if (i < array.length - 1) {
|
||||
link.append(paramSeparator);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
link.append(buildParameterSubstring(name, value != null ? value.toString() : StringUtils.EMPTY));
|
||||
link.append(buildParameterSubstring(name, value != null ? value.toString() : StringUtils.EMPTY, encode));
|
||||
}
|
||||
|
||||
if (iter.hasNext()) {
|
||||
@@ -250,11 +266,11 @@ public class DefaultUrlHelper implements UrlHelper {
|
||||
return HTTP_PROTOCOL.equals(scheme) || HTTPS_PROTOCOL.equals(scheme);
|
||||
}
|
||||
|
||||
private String buildParameterSubstring(String name, String value) {
|
||||
private String buildParameterSubstring(String name, String value, boolean encode) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(encode(name));
|
||||
builder.append(encode ? encode(name) : name);
|
||||
builder.append('=');
|
||||
builder.append(encode(value));
|
||||
builder.append(encode ? encode(value) : value);
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@@ -283,7 +299,7 @@ public class DefaultUrlHelper implements UrlHelper {
|
||||
*/
|
||||
public String decode( String input ) {
|
||||
try {
|
||||
return URLDecoderUtil.decode(input, encoding);
|
||||
return URLDecoderUtil.decode(input, encoding, false);
|
||||
} catch (Exception e) {
|
||||
if (LOG.isWarnEnabled()) {
|
||||
LOG.warn("Could not decode URL parameter '#0', returning value un-decoded", input);
|
||||
@@ -292,6 +308,22 @@ public class DefaultUrlHelper implements UrlHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the URL using {@link URLDecoderUtil#decode(String, String, boolean)} with the encoding specified in the configuration.
|
||||
*
|
||||
* @param input the input to decode
|
||||
* @param isQueryString whether input is a query string. If <code>true</code> other decoding rules apply.
|
||||
* @return the encoded string
|
||||
*/
|
||||
public String decode( String input, boolean isQueryString ) {
|
||||
try {
|
||||
return URLDecoderUtil.decode(input, encoding, isQueryString);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Could not decode URL parameter '{}', returning value un-decoded", input);
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Object> parseQueryString(String queryString, boolean forceValueArray) {
|
||||
Map<String, Object> queryParams = new LinkedHashMap<String, Object>();
|
||||
if (queryString != null) {
|
||||
@@ -308,8 +340,8 @@ public class DefaultUrlHelper implements UrlHelper {
|
||||
paramValue = tmpParams[1];
|
||||
}
|
||||
if (paramName != null) {
|
||||
paramName = decode(paramName);
|
||||
String translatedParamValue = decode(paramValue);
|
||||
paramName = decode(paramName, true);
|
||||
String translatedParamValue = decode(paramValue, true);
|
||||
|
||||
if (queryParams.containsKey(paramName) || forceValueArray) {
|
||||
// WW-1619 append new param value to existing value(s)
|
||||
|
||||
+18
-26
@@ -845,37 +845,14 @@ public class DefaultActionMapperTest extends StrutsInternalTestCase {
|
||||
String actionName = "action";
|
||||
assertEquals(actionName, mapper.cleanupActionName(actionName));
|
||||
|
||||
Throwable expected = null;
|
||||
|
||||
actionName = "${action}";
|
||||
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());
|
||||
assertEquals(mapper.defaultActionName, mapper.cleanupActionName(actionName));
|
||||
|
||||
actionName = "${${%{action}}}";
|
||||
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());
|
||||
assertEquals(mapper.defaultActionName, mapper.cleanupActionName(actionName));
|
||||
|
||||
actionName = "${#foo='action',#foo}";
|
||||
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());
|
||||
assertEquals(mapper.defaultActionName, mapper.cleanupActionName(actionName));
|
||||
|
||||
actionName = "test-action";
|
||||
assertEquals("test-action", mapper.cleanupActionName(actionName));
|
||||
@@ -887,4 +864,19 @@ public class DefaultActionMapperTest extends StrutsInternalTestCase {
|
||||
assertEquals("test!bar.action", mapper.cleanupActionName(actionName));
|
||||
}
|
||||
|
||||
public void testAllowedMethodNames() throws Exception {
|
||||
DefaultActionMapper mapper = new DefaultActionMapper();
|
||||
|
||||
assertEquals("", mapper.cleanupMethodName(""));
|
||||
assertEquals("test", mapper.cleanupMethodName("test"));
|
||||
assertEquals("test_method", mapper.cleanupMethodName("test_method"));
|
||||
assertEquals("_test", mapper.cleanupMethodName("_test"));
|
||||
assertEquals("test1", mapper.cleanupMethodName("test1"));
|
||||
|
||||
assertEquals(mapper.defaultMethodName, mapper.cleanupMethodName("2test"));
|
||||
assertEquals(mapper.defaultMethodName, mapper.cleanupMethodName("%{exp}"));
|
||||
assertEquals(mapper.defaultMethodName, mapper.cleanupMethodName("${%{foo}}"));
|
||||
assertEquals(mapper.defaultMethodName, mapper.cleanupMethodName("${#foo='method',#foo}"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -93,6 +93,10 @@ public class ComponentUtilsTest extends StrutsInternalTestCase {
|
||||
assertFalse(actual);
|
||||
}
|
||||
|
||||
public void testIsExpressionIsFalseWhenNull() throws Exception {
|
||||
assertFalse(ComponentUtils.isExpression(null));
|
||||
}
|
||||
|
||||
public void testContainsExpressionIsTrue() throws Exception {
|
||||
// given
|
||||
String anExpression = "%{foo}";
|
||||
@@ -125,6 +129,10 @@ public class ComponentUtilsTest extends StrutsInternalTestCase {
|
||||
// then
|
||||
assertFalse(actual);
|
||||
}
|
||||
|
||||
public void testContainsExpressionIsFalseWhenNull() throws Exception {
|
||||
assertFalse(ComponentUtils.containsExpression(null));
|
||||
}
|
||||
}
|
||||
|
||||
class MockConfigurationProvider implements ConfigurationProvider {
|
||||
|
||||
@@ -68,4 +68,11 @@ public class URLDecoderUtilTest {
|
||||
assertEquals("xxxx\u00ea", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testURLDecodePlusCharAsSpace() {
|
||||
|
||||
String result = URLDecoderUtil.decode("a+b", "UTF-8", true);
|
||||
assertEquals("a b", result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,21 +21,23 @@
|
||||
|
||||
package org.apache.struts2.views.util;
|
||||
|
||||
import com.mockobjects.dynamic.Mock;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.inject.Container;
|
||||
import com.opensymphony.xwork2.inject.Scope.Strategy;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.StrutsInternalTestCase;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.StrutsInternalTestCase;
|
||||
|
||||
import com.mockobjects.dynamic.Mock;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.inject.Container;
|
||||
import com.opensymphony.xwork2.inject.Scope.Strategy;
|
||||
|
||||
|
||||
/**
|
||||
* Test case for DefaultUrlHelper.
|
||||
@@ -393,7 +395,15 @@ public class DefaultUrlHelperTest extends StrutsInternalTestCase {
|
||||
|
||||
assertEquals(result, expectedResult);
|
||||
}
|
||||
|
||||
|
||||
public void testDecodeSpacesInQueryString() throws Exception {
|
||||
Map<String, Object> queryParameters = urlHelper.parseQueryString("name=value+with+space", false);
|
||||
|
||||
assertTrue(queryParameters.containsKey("name"));
|
||||
assertEquals("value with space", queryParameters.get("name"));
|
||||
}
|
||||
|
||||
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
stubContainer = new StubContainer(container);
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-cdi-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-codebehind-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-config-browser-plugin</artifactId>
|
||||
|
||||
+1
@@ -50,6 +50,7 @@ public class ShowBeansAction extends ActionNamesAction {
|
||||
|
||||
@Inject
|
||||
public void setContainer(Container container) {
|
||||
super.setContainer(container);
|
||||
bindings = new TreeMap<String, Set<Binding>>();
|
||||
bindings.put(ObjectFactory.class.getName(), addBindings(container, ObjectFactory.class, StrutsConstants.STRUTS_OBJECTFACTORY));
|
||||
bindings.put(XWorkConverter.class.getName(), addBindings(container, XWorkConverter.class, StrutsConstants.STRUTS_XWORKCONVERTER));
|
||||
|
||||
+1
@@ -36,6 +36,7 @@ public class ShowConstantsAction extends ActionNamesAction {
|
||||
|
||||
@Inject
|
||||
public void setContainer(Container container) {
|
||||
super.setContainer(container);
|
||||
constants = new HashMap<String, String>();
|
||||
for (String key : container.getInstanceNames(String.class)) {
|
||||
constants.put(key, container.getInstance(String.class, key));
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
-->
|
||||
<#include "tigris-macros.ftl">
|
||||
<@startPage pageTitle="Actions in namespace"/>
|
||||
<h3>Actions in <#if namespace == ""> default namespace <#else> ${namespace} </#if></h3>
|
||||
<h3>Actions in <#if namespace == ""> default namespace <#else> ${namespace?html} </#if></h3>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<tr><td>Action name:</td><td>${actionName}</td></tr>
|
||||
<tr><td>Namespace:</td><td> ${namespace}</td></tr>
|
||||
<tr><td>Action class:</td><td> ${config.className}</td></tr>
|
||||
<tr><td>Action method:</td><td> <#if config.methodName?exists>${config.methodName}</#if></td></tr>
|
||||
<tr><td>Action method:</td><td> <#if config.methodName??>${config.methodName}</#if></td></tr>
|
||||
<tr><td>Parameters:</td><td> <#list config.params?keys as p>
|
||||
${p}
|
||||
</#list></td></tr>
|
||||
@@ -41,9 +41,9 @@
|
||||
</table>
|
||||
|
||||
<!-- URLTag is faulty -->
|
||||
<@s.url id="url" action="showConfig" includeParams="none">
|
||||
<@s.param name="namespace">${namespace}</@s.param>
|
||||
<@s.param name="actionName">${actionName}</@s.param>
|
||||
<@s.url var="url" action="showConfig" includeParams="none">
|
||||
<@s.param name="namespace">${namespace?html}</@s.param>
|
||||
<@s.param name="actionName">${actionName?html}</@s.param>
|
||||
</@s.url>
|
||||
<#assign url = url + "&detailView=">
|
||||
<!-- Set all to false -->
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<#call startPage pageTitle="Validator Details"/>
|
||||
<table>
|
||||
<tr><td>Validated Class:</td><td>${action.stripPackage(clazz)}</td></tr>
|
||||
<tr><td>Context:</td><td>${context}</td></tr>
|
||||
<tr><td>Context:</td><td>${context?html}</td></tr>
|
||||
<tr><td>Validator Number:</td><td>${selected}</td></tr>
|
||||
<tr><td>Validator Type:</td><td>${action.stripPackage(selectedValidator.class)}</td></tr>
|
||||
</table>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-convention-plugin</artifactId>
|
||||
|
||||
+18
-10
@@ -43,6 +43,7 @@ import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -332,27 +333,34 @@ public class ConventionUnknownHandler implements UnknownHandler {
|
||||
Map<String, ResultTypeConfig> resultsByExtension) {
|
||||
try {
|
||||
boolean traceEnabled = LOG.isTraceEnabled();
|
||||
if (traceEnabled)
|
||||
if (traceEnabled) {
|
||||
LOG.trace("Checking ServletContext for [#0]", path);
|
||||
}
|
||||
|
||||
if (servletContext.getResource(path) != null) {
|
||||
if (traceEnabled)
|
||||
LOG.trace("Found");
|
||||
URL resource = servletContext.getResource(path);
|
||||
if (resource != null && resource.getPath().endsWith(path)) {
|
||||
if (traceEnabled) {
|
||||
LOG.trace("Found resource #0", resource);
|
||||
}
|
||||
return buildResult(path, resultCode, resultsByExtension.get(ext), actionContext);
|
||||
}
|
||||
|
||||
if (traceEnabled)
|
||||
LOG.trace("Checking ClasLoader for #0", path);
|
||||
if (traceEnabled) {
|
||||
LOG.trace("Checking ClassLoader for #0", path);
|
||||
}
|
||||
|
||||
String classLoaderPath = path.startsWith("/") ? path.substring(1, path.length()) : path;
|
||||
if (ClassLoaderUtil.getResource(classLoaderPath, getClass()) != null) {
|
||||
if (traceEnabled)
|
||||
LOG.trace("Found");
|
||||
resource = ClassLoaderUtil.getResource(classLoaderPath, getClass());
|
||||
if (resource != null && resource.getPath().endsWith(classLoaderPath)) {
|
||||
if (traceEnabled) {
|
||||
LOG.trace("Found resource #0", resource);
|
||||
}
|
||||
return buildResult(path, resultCode, resultsByExtension.get(ext), actionContext);
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
if (LOG.isErrorEnabled())
|
||||
if (LOG.isErrorEnabled()) {
|
||||
LOG.error("Unable to parse template path: [#0] skipping...", path);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
+19
-7
@@ -107,14 +107,26 @@ public class ConventionsServiceImpl implements ConventionsService {
|
||||
public Map<String, ResultTypeConfig> getResultTypesByExtension(PackageConfig packageConfig) {
|
||||
Map<String, ResultTypeConfig> results = packageConfig.getAllResultTypeConfigs();
|
||||
|
||||
ResultTypeConfig dispatcher = disableParse(results.get("dispatcher"));
|
||||
ResultTypeConfig velocity = disableParse(results.get("velocity"));
|
||||
ResultTypeConfig freemarker = disableParse(results.get("freemarker"));
|
||||
|
||||
Map<String, ResultTypeConfig> resultsByExtension = new HashMap<String, ResultTypeConfig>();
|
||||
resultsByExtension.put("jsp", results.get("dispatcher"));
|
||||
resultsByExtension.put("jspf", results.get("dispatcher"));
|
||||
resultsByExtension.put("jspx", results.get("dispatcher"));
|
||||
resultsByExtension.put("vm", results.get("velocity"));
|
||||
resultsByExtension.put("ftl", results.get("freemarker"));
|
||||
resultsByExtension.put("html", results.get("dispatcher"));
|
||||
resultsByExtension.put("htm", results.get("dispatcher"));
|
||||
resultsByExtension.put("jsp", dispatcher);
|
||||
resultsByExtension.put("jspf", dispatcher);
|
||||
resultsByExtension.put("jspx", dispatcher);
|
||||
resultsByExtension.put("vm", velocity);
|
||||
resultsByExtension.put("ftl", freemarker);
|
||||
resultsByExtension.put("html", dispatcher);
|
||||
resultsByExtension.put("htm", dispatcher);
|
||||
return resultsByExtension;
|
||||
}
|
||||
|
||||
private ResultTypeConfig disableParse(ResultTypeConfig resultConfig) {
|
||||
if (resultConfig != null) {
|
||||
return new ResultTypeConfig.Builder(resultConfig).addParam("parse", "false").build();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</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.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-dwr-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</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.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-gxp-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-jasperreports-plugin</artifactId>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</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.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-javatemplates-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</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.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-jsf-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-json-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-junit-plugin</artifactId>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-osgi-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-oval-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</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.30</version>
|
||||
<version>2.3.32</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.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</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.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-portlet-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-rest-plugin</artifactId>
|
||||
|
||||
@@ -112,6 +112,7 @@ public class RestActionMapper extends DefaultActionMapper {
|
||||
private boolean allowDynamicMethodCalls = false;
|
||||
|
||||
public RestActionMapper() {
|
||||
this.defaultMethodName = indexMethodName;
|
||||
}
|
||||
|
||||
public String getIdParameterName() {
|
||||
@@ -290,7 +291,7 @@ public class RestActionMapper extends DefaultActionMapper {
|
||||
fullName = fullName.substring(0, lastSlashPos);
|
||||
}
|
||||
|
||||
mapping.setName(fullName);
|
||||
mapping.setName(cleanupActionName(fullName));
|
||||
}
|
||||
return mapping;
|
||||
}
|
||||
@@ -311,7 +312,7 @@ public class RestActionMapper extends DefaultActionMapper {
|
||||
|
||||
mapping.setName(actionName);
|
||||
if (allowDynamicMethodCalls) {
|
||||
mapping.setMethod(cleanupActionName(actionMethod));
|
||||
mapping.setMethod(cleanupMethodName(actionMethod));
|
||||
} else {
|
||||
mapping.setMethod(null);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-sitegraph-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-sitemesh-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-spring-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-struts1-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-testng-plugin</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-tiles-plugin</artifactId>
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.struts2.tiles;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.LocaleProvider;
|
||||
import com.opensymphony.xwork2.TextProvider;
|
||||
import com.opensymphony.xwork2.TextProviderFactory;
|
||||
import com.opensymphony.xwork2.config.ConfigurationException;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.tiles.context.TilesRequestContext;
|
||||
import org.apache.tiles.evaluator.AbstractAttributeEvaluator;
|
||||
import org.apache.tiles.servlet.context.ServletUtil;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
public class I18NAttributeEvaluator extends AbstractAttributeEvaluator {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(I18NAttributeEvaluator.class);
|
||||
|
||||
public Object evaluate(String expression, TilesRequestContext request) {
|
||||
Object result = expression;
|
||||
|
||||
HttpServletRequest httpRequest = ServletUtil.getServletRequest(request).getRequest();
|
||||
ActionContext ctx = ServletActionContext.getActionContext(httpRequest);
|
||||
|
||||
if (ctx == null) {
|
||||
LOG.error("Cannot obtain HttpServletRequest from [{}]", request.getClass().getName());
|
||||
throw new ConfigurationException("There is no ActionContext for current request!");
|
||||
}
|
||||
|
||||
TextProviderFactory tpf = new TextProviderFactory();
|
||||
ctx.getContainer().inject(tpf);
|
||||
LocaleProvider localeProvider = ctx.getContainer().getInstance(LocaleProvider.class);
|
||||
|
||||
TextProvider textProvider = tpf.createInstance(ctx.getActionInvocation().getAction().getClass(), localeProvider);
|
||||
|
||||
if (textProvider != null) {
|
||||
LOG.debug("Trying find text [{}] using TextProvider {}", expression, textProvider);
|
||||
result = textProvider.getText(expression);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void init(Map<String, String> initParameters) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.struts2.tiles;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.config.ConfigurationException;
|
||||
import com.opensymphony.xwork2.ognl.OgnlUtil;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
import ognl.OgnlException;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.tiles.context.TilesRequestContext;
|
||||
import org.apache.tiles.evaluator.AbstractAttributeEvaluator;
|
||||
import org.apache.tiles.evaluator.EvaluationException;
|
||||
import org.apache.tiles.servlet.context.ServletUtil;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
public class StrutsAttributeEvaluator extends AbstractAttributeEvaluator {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(StrutsAttributeEvaluator.class);
|
||||
|
||||
public Object evaluate(String expression, TilesRequestContext request) {
|
||||
try {
|
||||
HttpServletRequest httpRequest = ServletUtil.getServletRequest(request).getRequest();
|
||||
ActionContext ctx = ServletActionContext.getActionContext(httpRequest);
|
||||
|
||||
if (ctx == null) {
|
||||
LOG.error("Cannot obtain HttpServletRequest from [{}]", request.getClass().getName());
|
||||
throw new ConfigurationException("There is no ActionContext for current request!");
|
||||
}
|
||||
|
||||
OgnlUtil ognlUtil = ctx.getContainer().getInstance(OgnlUtil.class);
|
||||
|
||||
LOG.debug("Trying evaluate expression [{}] using OgnlUtil's getValue", expression);
|
||||
Object result = ognlUtil.getValue(expression, ctx.getContextMap(), ctx.getValueStack().getRoot());
|
||||
|
||||
LOG.debug("Final result of evaluating expression [{}] is: {}", expression, result);
|
||||
|
||||
return result;
|
||||
} catch (OgnlException e) {
|
||||
throw new EvaluationException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void init(Map<String, String> initParameters) {
|
||||
}
|
||||
}
|
||||
+27
-4
@@ -83,9 +83,10 @@ import java.util.Set;
|
||||
/**
|
||||
* Dedicated Struts factory to build Tiles container with support for:
|
||||
* - Freemarker
|
||||
* - OGNL (as default)
|
||||
* - I18N using Struts resource bundles
|
||||
* - S2 ro access Struts' ValueStack
|
||||
* - OGNL
|
||||
* - EL
|
||||
* - Wildcards
|
||||
*
|
||||
* If you need additional features create your own listener and factory,
|
||||
* you can base on code from Tiles' CompleteAutoloadTilesContainerFactory
|
||||
@@ -108,6 +109,14 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory {
|
||||
*/
|
||||
public static final String TILES_DEFAULT_PATTERN = "tiles*.xml";
|
||||
|
||||
/**
|
||||
* Supported expression languages
|
||||
*/
|
||||
public static final String OGNL = "OGNL";
|
||||
public static final String EL = "EL";
|
||||
public static final String S2 = "S2";
|
||||
public static final String I18N = "I18N";
|
||||
|
||||
@Override
|
||||
protected BasicTilesContainer instantiateContainer(TilesApplicationContext applicationContext) {
|
||||
CachingTilesContainer tilesContainer = new CachingTilesContainer();
|
||||
@@ -182,8 +191,14 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory {
|
||||
LocaleResolver resolver) {
|
||||
|
||||
BasicAttributeEvaluatorFactory attributeEvaluatorFactory = new BasicAttributeEvaluatorFactory(new DirectAttributeEvaluator());
|
||||
attributeEvaluatorFactory.registerAttributeEvaluator("OGNL", createOGNLEvaluator());
|
||||
attributeEvaluatorFactory.registerAttributeEvaluator("EL", createELEvaluator(applicationContext));
|
||||
attributeEvaluatorFactory.registerAttributeEvaluator(S2, createStrutsEvaluator());
|
||||
attributeEvaluatorFactory.registerAttributeEvaluator(I18N, createI18NEvaluator());
|
||||
attributeEvaluatorFactory.registerAttributeEvaluator(OGNL, createOGNLEvaluator());
|
||||
|
||||
ELAttributeEvaluator elEvaluator = createELEvaluator(applicationContext);
|
||||
if (elEvaluator != null) {
|
||||
attributeEvaluatorFactory.registerAttributeEvaluator(EL, elEvaluator);
|
||||
}
|
||||
|
||||
return attributeEvaluatorFactory;
|
||||
}
|
||||
@@ -252,6 +267,14 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory {
|
||||
return evaluator;
|
||||
}
|
||||
|
||||
protected StrutsAttributeEvaluator createStrutsEvaluator() {
|
||||
return new StrutsAttributeEvaluator();
|
||||
}
|
||||
|
||||
protected I18NAttributeEvaluator createI18NEvaluator() {
|
||||
return new I18NAttributeEvaluator();
|
||||
}
|
||||
|
||||
protected OGNLAttributeEvaluator createOGNLEvaluator() {
|
||||
try {
|
||||
PropertyAccessor objectPropertyAccessor = OgnlRuntime.getPropertyAccessor(Object.class);
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-tiles3-plugin</artifactId>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</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_30</tag>
|
||||
<tag>STRUTS_2_3_32</tag>
|
||||
</scm>
|
||||
|
||||
<issueManagement>
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>2.3.30</version>
|
||||
<version>2.3.32</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.apache.struts.xwork</groupId>
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ public class ResultTypeConfig extends Located implements Serializable {
|
||||
this.name = orig.name;
|
||||
this.className = orig.className;
|
||||
this.defaultResultParam = orig.defaultResultParam;
|
||||
this.params = orig.params;
|
||||
this.params = new LinkedHashMap<String, String>(orig.params);
|
||||
this.location = orig.location;
|
||||
}
|
||||
|
||||
|
||||
+8
-6
@@ -184,12 +184,14 @@ public class InterceptorBuilder {
|
||||
Interceptor interceptor = objectFactory.buildInterceptor(cfg, map);
|
||||
|
||||
InterceptorMapping mapping = new InterceptorMapping(key, interceptor);
|
||||
if (result != null && result.contains(mapping)) {
|
||||
// if an existing interceptor mapping exists,
|
||||
// we remove from the result Set, just to make sure
|
||||
// there's always one unique mapping.
|
||||
int index = result.indexOf(mapping);
|
||||
result.set(index, mapping);
|
||||
if (result.contains(mapping)) {
|
||||
for (int index = 0; index < result.size(); index++) {
|
||||
InterceptorMapping interceptorMapping = result.get(index);
|
||||
if (interceptorMapping.getName().equals(key)) {
|
||||
LOG.debug("Overriding interceptor config [#0] with new mapping #1 using new params #2", key, interceptorMapping, map);
|
||||
result.set(index, mapping);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result.add(mapping);
|
||||
}
|
||||
|
||||
+46
@@ -9,6 +9,7 @@ import com.opensymphony.xwork2.config.entities.InterceptorStackConfig;
|
||||
import com.opensymphony.xwork2.config.entities.PackageConfig;
|
||||
import com.opensymphony.xwork2.interceptor.Interceptor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -78,6 +79,51 @@ public class InterceptorBuilderTest extends XWorkTestCase {
|
||||
assertEquals(((MockInterceptor2) ((InterceptorMapping) interceptorMappings.get(1)).getInterceptor()).getParam2(), "interceptor2_value2");
|
||||
}
|
||||
|
||||
public void testMultipleSameInterceptors() throws Exception {
|
||||
InterceptorConfig interceptorConfig1 = new InterceptorConfig.Builder("interceptor1", "com.opensymphony.xwork2.config.providers.InterceptorBuilderTest$MockInterceptor1").build();
|
||||
InterceptorConfig interceptorConfig2 = new InterceptorConfig.Builder("interceptor2", "com.opensymphony.xwork2.config.providers.InterceptorBuilderTest$MockInterceptor2").build();
|
||||
|
||||
InterceptorStackConfig interceptorStackConfig1 = new InterceptorStackConfig.Builder("multiStack")
|
||||
.addInterceptor(new InterceptorMapping(interceptorConfig1.getName(), objectFactory.buildInterceptor(interceptorConfig1, Collections.<String, String>emptyMap())))
|
||||
.addInterceptor(new InterceptorMapping(interceptorConfig2.getName(), objectFactory.buildInterceptor(interceptorConfig2, Collections.<String, String>emptyMap())))
|
||||
.addInterceptor(new InterceptorMapping(interceptorConfig1.getName(), objectFactory.buildInterceptor(interceptorConfig1, Collections.<String, String>emptyMap())))
|
||||
.build();
|
||||
|
||||
PackageConfig packageConfig = new PackageConfig.Builder("package1")
|
||||
.namespace("/namespace")
|
||||
.addInterceptorConfig(interceptorConfig1)
|
||||
.addInterceptorConfig(interceptorConfig2)
|
||||
.addInterceptorConfig(interceptorConfig1)
|
||||
.addInterceptorStackConfig(interceptorStackConfig1)
|
||||
.build();
|
||||
|
||||
List interceptorMappings = InterceptorBuilder.constructInterceptorReference(packageConfig, "multiStack",
|
||||
new LinkedHashMap<String, String>() {
|
||||
{
|
||||
put("interceptor1.param1", "interceptor1_value1");
|
||||
put("interceptor1.param2", "interceptor1_value2");
|
||||
}
|
||||
}, null, objectFactory);
|
||||
|
||||
assertEquals(interceptorMappings.size(), 3);
|
||||
|
||||
assertEquals(((InterceptorMapping) interceptorMappings.get(0)).getName(), "interceptor1");
|
||||
assertNotNull(((InterceptorMapping) interceptorMappings.get(0)).getInterceptor());
|
||||
assertEquals(((InterceptorMapping) interceptorMappings.get(0)).getInterceptor().getClass(), MockInterceptor1.class);
|
||||
assertEquals(((MockInterceptor1) ((InterceptorMapping) interceptorMappings.get(0)).getInterceptor()).getParam1(), "interceptor1_value1");
|
||||
assertEquals(((MockInterceptor1) ((InterceptorMapping) interceptorMappings.get(0)).getInterceptor()).getParam2(), "interceptor1_value2");
|
||||
|
||||
assertEquals(((InterceptorMapping) interceptorMappings.get(1)).getName(), "interceptor2");
|
||||
assertNotNull(((InterceptorMapping) interceptorMappings.get(1)).getInterceptor());
|
||||
assertEquals(((InterceptorMapping) interceptorMappings.get(1)).getInterceptor().getClass(), MockInterceptor2.class);
|
||||
|
||||
assertEquals(((InterceptorMapping) interceptorMappings.get(2)).getName(), "interceptor1");
|
||||
assertNotNull(((InterceptorMapping) interceptorMappings.get(2)).getInterceptor());
|
||||
assertEquals(((InterceptorMapping) interceptorMappings.get(2)).getInterceptor().getClass(), MockInterceptor1.class);
|
||||
assertEquals(((MockInterceptor1) ((InterceptorMapping) interceptorMappings.get(2)).getInterceptor()).getParam1(), "interceptor1_value1");
|
||||
assertEquals(((MockInterceptor1) ((InterceptorMapping) interceptorMappings.get(2)).getInterceptor()).getParam2(), "interceptor1_value2");
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to test this
|
||||
* <interceptor-ref name="interceptorStack1">
|
||||
|
||||
@@ -17,7 +17,6 @@ package com.opensymphony.xwork2.validator;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.XWorkTestCase;
|
||||
import com.opensymphony.xwork2.util.URLUtil;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.validator.validators.URLValidator;
|
||||
|
||||
@@ -132,14 +131,18 @@ public class URLValidatorTest extends XWorkTestCase {
|
||||
public void testValidUrlWithDefaultRegex() throws Exception {
|
||||
URLValidator validator = new URLValidator();
|
||||
|
||||
Pattern pattern = Pattern.compile(validator.getUrlRegex());
|
||||
Pattern pattern = Pattern.compile(validator.getUrlRegex(), Pattern.CASE_INSENSITIVE);
|
||||
|
||||
assertFalse(pattern.matcher("myapp://test.com").matches());
|
||||
assertFalse(pattern.matcher("myap://test.com").matches());
|
||||
assertFalse(pattern.matcher("").matches());
|
||||
assertFalse(pattern.matcher(" ").matches());
|
||||
assertFalse(pattern.matcher("no url").matches());
|
||||
assertFalse(pattern.matcher("http://example.com////////////////////////////////////////////////////////////////////////////////////??").matches());
|
||||
assertFalse(pattern.matcher("http://example.com////////////////////////////////////////////////////////////////////////////////////??").matches());
|
||||
|
||||
assertTrue(pattern.matcher("http://www.legalspace.com/__media__/js/netsoltrademark.php?d=www.a-vos-travaux.fr%2Facheter-un-aspirateur-sans-sac-pas-cher%2F").matches());
|
||||
assertTrue(pattern.matcher("http://www.duadmin.isaev.Infoduadmin.Isaev.info/?a%5B%5D=%3Ca%20href%3Dhttp%3A%2F%2Fwww.aspert.fr%2Fun-seche-cheveux-lisseur-est-il-vraiment-utile%2F%3Eseche%20cheveux%20dyson%20test%3C%2Fa").matches());
|
||||
assertTrue(pattern.matcher("http://netsol-underconstruction-page-monitor-1.com/__media__/js/netsoltrademark.php?d=www.le-soutien-scolaire.fr%2Favis-et-test-comparatifs-des-robots-multifonctions%2F").matches());
|
||||
|
||||
assertTrue(pattern.matcher("http://www.opensymphony.com").matches());
|
||||
assertTrue(pattern.matcher("https://www.opensymphony.com").matches());
|
||||
@@ -181,7 +184,7 @@ public class URLValidatorTest extends XWorkTestCase {
|
||||
}
|
||||
|
||||
public String getTestingUrl5() {
|
||||
return "http://yahoo.com/articles?id=123";
|
||||
return "http://yahoo.com/articles?id=123\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user