Revision: 422
          http://svn.sourceforge.net/stripes/?rev=422&view=rev
Author:   tfenne
Date:     2006-09-28 16:28:02 -0700 (Thu, 28 Sep 2006)

Log Message:
-----------
Fix to ensure that parameter values aren't HTML encoded twice in error messages.

Modified Paths:
--------------
    trunk/stripes/src/net/sourceforge/stripes/controller/DispatcherHelper.java

Modified: 
trunk/stripes/src/net/sourceforge/stripes/controller/DispatcherHelper.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/controller/DispatcherHelper.java  
2006-09-26 12:05:28 UTC (rev 421)
+++ trunk/stripes/src/net/sourceforge/stripes/controller/DispatcherHelper.java  
2006-09-28 23:28:02 UTC (rev 422)
@@ -357,10 +357,11 @@
     public static void fillInValidationErrors(ExecutionContext ctx) {
         ActionBeanContext context = ctx.getActionBeanContext();
         ValidationErrors errors = context.getValidationErrors();
-        HttpServletRequest request = context.getRequest();
 
         if (errors.size() > 0) {
-            String formAction = (String) 
request.getAttribute(ActionResolver.RESOLVED_ACTION);
+            String formAction = 
StripesFilter.getConfiguration().getActionResolver()
+                    .getUrlBinding(ctx.getActionBean().getClass());
+            HttpServletRequest request = 
ctx.getActionBeanContext().getRequest();
 
             /** Since we don't pass form action down the stack, we add it to 
the errors here. */
             for (Map.Entry<String, List<ValidationError>> entry : 
errors.entrySet()) {
@@ -368,16 +369,18 @@
                 List<ValidationError> listOfErrors = entry.getValue();
 
                 for (ValidationError error : listOfErrors) {
-                    error.setActionPath(formAction);
+                    // Make sure we process each error only once, no matter 
how often we're called
+                    if (error.getActionPath() == null) {
+                        error.setActionPath(formAction);
 
-                    // This is done to fill in parameter values for any errors 
the user
-                    // created and didn't add values to
-                    if (error.getFieldValue() == null) {
-                        
error.setFieldValue(HtmlUtil.encode(request.getParameter(parameterName)));
+                        // If the value isn't set, set it, otherwise encode 
the one that's there
+                        if (error.getFieldValue() == null) {
+                            
error.setFieldValue(HtmlUtil.encode(request.getParameter(parameterName)));
+                        }
+                        else {
+                            
error.setFieldValue(HtmlUtil.encode(error.getFieldValue()));
+                        }
                     }
-                    else {
-                        
error.setFieldValue(HtmlUtil.encode(error.getFieldValue()));
-                    }
                 }
             }
         }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to