use of com.opensymphony.xwork2.conversion.impl.ConversionData in project struts by apache.
the class ConversionErrorInterceptorTest method testWithPreResultListenerAgainstMaliciousCode.
/**
* See WW-3668
*/
public void testWithPreResultListenerAgainstMaliciousCode() throws Exception {
conversionErrors.put("foo", new ConversionData("\" + #root + \"", int.class));
ActionContext ac = createActionContext();
MockActionInvocation mai = createActionInvocation(ac);
SimpleAction action = createAction(mai);
assertNull(action.getFieldErrors().get("foo"));
assertEquals(55, stack.findValue("foo"));
interceptor.doIntercept(mai);
assertTrue(action.hasFieldErrors());
assertNotNull(action.getFieldErrors().get("foo"));
assertEquals("\" + #root + \"", stack.findValue("foo"));
}
use of com.opensymphony.xwork2.conversion.impl.ConversionData in project struts by apache.
the class ConversionErrorInterceptorTest method testWithPreResultListener.
public void testWithPreResultListener() throws Exception {
conversionErrors.put("foo", new ConversionData("Hello", int.class));
ActionContext ac = createActionContext();
MockActionInvocation mai = createActionInvocation(ac);
SimpleAction action = createAction(mai);
assertNull(action.getFieldErrors().get("foo"));
assertEquals(55, stack.findValue("foo"));
interceptor.doIntercept(mai);
assertTrue(action.hasFieldErrors());
assertNotNull(action.getFieldErrors().get("foo"));
// assume that the original value is reset
assertEquals("Hello", stack.findValue("foo"));
}
Aggregations