Commits

plightbo  committed 295e1a2

port of WW-214 to webwork 2.0 / xwork 1.0

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@115e221344d-f017-0410-9bd5-d282ab1896d7

  • Participants
  • Parent commits e853b96

Comments (0)

Files changed (2)

File src/java/com/opensymphony/xwork/interceptor/NoParameters.java

+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork.interceptor;
+
+/**
+* This marker interface should be implemented by actions that do not want any
+* parameters set on them automatically (by the ParametersActionFactoryProxy)
+* This may be useful if one is using the action tag and want to supply
+* the parameters to the action manually using the param tag.
+* It may also be useful if one for security reasons wants to make sure that
+* parameters cannot be set by malicious users.
+*
+* @author	Dick Zetterberg (dick@transitor.se)
+* @version	$Revision$, $Date$
+*/
+public interface NoParameters
+{
+}

File src/java/com/opensymphony/xwork/interceptor/ParametersInterceptor.java

     }
 
     protected void before(ActionInvocation invocation) throws Exception {
-        final Map parameters = ActionContext.getContext().getParameters();
+        if (!(invocation.getAction() instanceof NoParameters)) {
+            final Map parameters = ActionContext.getContext().getParameters();
 
-        if (log.isDebugEnabled()) {
-            log.debug("Setting params " + parameters);
-        }
+            if (log.isDebugEnabled()) {
+                log.debug("Setting params " + parameters);
+            }
 
-        try {
-            InstantiatingNullHandler.setState(true);
-            invocation.getInvocationContext().put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);
+            try {
+                InstantiatingNullHandler.setState(true);
+                invocation.getInvocationContext().put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);
 
-            if (parameters != null) {
-                final OgnlValueStack stack = ActionContext.getContext().getValueStack();
+                if (parameters != null) {
+                    final OgnlValueStack stack = ActionContext.getContext().getValueStack();
 
-                for (Iterator iterator = parameters.entrySet().iterator();
-                        iterator.hasNext();) {
-                    Map.Entry entry = (Map.Entry) iterator.next();
-                    stack.setValue(entry.getKey().toString(), entry.getValue());
+                    for (Iterator iterator = parameters.entrySet().iterator();
+                         iterator.hasNext();) {
+                        Map.Entry entry = (Map.Entry) iterator.next();
+                        stack.setValue(entry.getKey().toString(), entry.getValue());
+                    }
                 }
+            } finally {
+                invocation.getInvocationContext().put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.FALSE);
+                InstantiatingNullHandler.setState(false);
             }
-        } finally {
-            invocation.getInvocationContext().put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.FALSE);
-            InstantiatingNullHandler.setState(false);
         }
     }
 }