mirror of
https://github.com/apache/struts.git
synced 2026-08-11 01:27:14 +00:00
Prevents eval expressions at all
This commit is contained in:
committed by
Lukasz Lenart
parent
46f3cf24c4
commit
61f9b07a78
@@ -273,14 +273,10 @@ public class OgnlUtil {
|
||||
*
|
||||
* @throws OgnlException in case of ognl errors
|
||||
*/
|
||||
public void setValue(String name, Map<String, Object> context, Object root, Object value) throws OgnlException {
|
||||
setValue(name, context, root, value, true);
|
||||
}
|
||||
|
||||
protected void setValue(String name, final Map<String, Object> context, final Object root, final Object value, final boolean evalName) throws OgnlException {
|
||||
public void setValue(final String name, final Map<String, Object> context, final Object root, final Object value) throws OgnlException {
|
||||
compileAndExecute(name, context, new OgnlTask<Void>() {
|
||||
public Void execute(Object tree) throws OgnlException {
|
||||
if (!evalName && isEvalExpression(tree, context)) {
|
||||
if (isEvalExpression(tree, context)) {
|
||||
throw new OgnlException("Eval expression cannot be used as parameter name");
|
||||
}
|
||||
Ognl.setValue(tree, context, root, value);
|
||||
|
||||
@@ -148,7 +148,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
|
||||
* @see com.opensymphony.xwork2.util.ValueStack#setParameter(String, Object)
|
||||
*/
|
||||
public void setParameter(String expr, Object value) {
|
||||
setValue(expr, value, devMode, false);
|
||||
setValue(expr, value, devMode);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,13 +164,9 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
|
||||
* @see com.opensymphony.xwork2.util.ValueStack#setValue(java.lang.String, java.lang.Object, boolean)
|
||||
*/
|
||||
public void setValue(String expr, Object value, boolean throwExceptionOnFailure) {
|
||||
setValue(expr, value, throwExceptionOnFailure, true);
|
||||
}
|
||||
|
||||
private void setValue(String expr, Object value, boolean throwExceptionOnFailure, boolean evalExpression) {
|
||||
Map<String, Object> context = getContext();
|
||||
try {
|
||||
trySetValue(expr, value, throwExceptionOnFailure, context, evalExpression);
|
||||
trySetValue(expr, value, throwExceptionOnFailure, context);
|
||||
} catch (OgnlException e) {
|
||||
handleOgnlException(expr, value, throwExceptionOnFailure, e);
|
||||
} catch (RuntimeException re) { //XW-281
|
||||
@@ -180,10 +176,10 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
|
||||
}
|
||||
}
|
||||
|
||||
private void trySetValue(String expr, Object value, boolean throwExceptionOnFailure, Map<String, Object> context, boolean evalExpression) throws OgnlException {
|
||||
private void trySetValue(String expr, Object value, boolean throwExceptionOnFailure, Map<String, Object> context) throws OgnlException {
|
||||
context.put(XWorkConverter.CONVERSION_PROPERTY_FULLNAME, expr);
|
||||
context.put(REPORT_ERRORS_ON_NO_PROP, (throwExceptionOnFailure) ? Boolean.TRUE : Boolean.FALSE);
|
||||
ognlUtil.setValue(expr, context, root, value, evalExpression);
|
||||
ognlUtil.setValue(expr, context, root, value);
|
||||
}
|
||||
|
||||
private void cleanUpContext(Map<String, Object> context) {
|
||||
|
||||
Reference in New Issue
Block a user