[seam-commits] Seam SVN: r14219 - in branches/community/Seam_2_3/jboss-seam/src/main: java/org/jboss/seam/exception and 2 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Sat Oct 8 05:34:35 EDT 2011


Author: manaRH
Date: 2011-10-08 05:34:34 -0400 (Sat, 08 Oct 2011)
New Revision: 14219

Modified:
   branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/core/Expressions.java
   branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/exception/ErrorHandler.java
   branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/exception/RedirectHandler.java
   branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/faces/Navigator.java
   branches/community/Seam_2_3/jboss-seam/src/main/resources/org/jboss/seam/blacklist.properties
Log:
JBSEAM-4844 - fixed exception handler of EL

Modified: branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/core/Expressions.java
===================================================================
--- branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/core/Expressions.java	2011-10-07 00:42:43 UTC (rev 14218)
+++ branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/core/Expressions.java	2011-10-08 09:34:34 UTC (rev 14219)
@@ -10,6 +10,7 @@
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.regex.Pattern;
 
 import javax.el.ELContext;
 import javax.el.ExpressionFactory;
@@ -304,23 +305,28 @@
        }
    }
    
+   // optimalization of REGEX
+   final static String WHITESPACE_REGEX_STRING = "\\s";
+   final static Pattern WHITESPACE_REGEX_PATTERN = Pattern.compile(WHITESPACE_REGEX_STRING);
+   
    private static void checkELExpression(final String expression)
    {
-	  
       if (expression == null)
       {
          return;
       }
       
+      final String expressionTrimmed = WHITESPACE_REGEX_PATTERN.matcher(expression).replaceAll("");
+      
       for (int index = 0; blacklist.size() > index; index++)
       {
-         if ( expression.contains(blacklist.get(index)) ) {
+         if ( expressionTrimmed.contains(blacklist.get(index)) ) {
             throw new IllegalArgumentException("This EL expression is not allowed!");
          }
       }
       
       // for any case blacklist is not provided this is definitely not permitted
-      if ( expression.contains(".getClass()") || expression.contains(".class()") )
+      if ( expressionTrimmed.contains(".getClass(") ||  expressionTrimmed.contains(".class.") )
       {
          throw new IllegalArgumentException("This EL expression is not allowed!");
       }

Modified: branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/exception/ErrorHandler.java
===================================================================
--- branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/exception/ErrorHandler.java	2011-10-07 00:42:43 UTC (rev 14218)
+++ branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/exception/ErrorHandler.java	2011-10-08 09:34:34 UTC (rev 14219)
@@ -2,7 +2,6 @@
 
 import org.jboss.seam.contexts.Contexts;
 import org.jboss.seam.core.Conversation;
-import org.jboss.seam.core.Interpolator;
 
 /**
  * Base implementation of HTTP error exception handlers.
@@ -25,8 +24,7 @@
          Conversation.instance().end();
       }
       
-      String msg = getDisplayMessage( e, getMessage(e) );
-      msg = msg==null ? null : Interpolator.instance().interpolate(msg);
+      String msg = getDisplayMessage( e, getMessage(e) );      
       error( getCode(e), msg );
    }
 

Modified: branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/exception/RedirectHandler.java
===================================================================
--- branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/exception/RedirectHandler.java	2011-10-07 00:42:43 UTC (rev 14218)
+++ branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/exception/RedirectHandler.java	2011-10-08 09:34:34 UTC (rev 14219)
@@ -39,7 +39,7 @@
          viewId = servletPath.substring(0, servletPath.lastIndexOf('.')) + Pages.getSuffix();
       }
       
-      addFacesMessage( getDisplayMessage(e, getMessage(e)), getMessageSeverity(e), null, e );
+      addFacesMessage( "#0", getMessageSeverity(e), null, getDisplayMessage(e, getMessage(e)));
       
       if ( Contexts.isConversationContextActive() && isEnd(e) ) 
       {

Modified: branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/faces/Navigator.java
===================================================================
--- branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/faces/Navigator.java	2011-10-07 00:42:43 UTC (rev 14218)
+++ branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/faces/Navigator.java	2011-10-08 09:34:34 UTC (rev 14219)
@@ -7,6 +7,7 @@
 import javax.faces.context.FacesContext;
 
 import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.core.Interpolator;
 import org.jboss.seam.log.LogProvider;
 import org.jboss.seam.log.Logging;
 import org.jboss.seam.navigation.Pages;
@@ -79,11 +80,11 @@
    {
       if ( Strings.isEmpty(message) && e.getMessage()!=null ) 
       {
-         return e.getMessage();
+    	  return e.getMessage();
       }
       else
       {
-         return message;
+    	  return Interpolator.instance().interpolate(message, e);
       }
    }
    

Modified: branches/community/Seam_2_3/jboss-seam/src/main/resources/org/jboss/seam/blacklist.properties
===================================================================
--- branches/community/Seam_2_3/jboss-seam/src/main/resources/org/jboss/seam/blacklist.properties	2011-10-07 00:42:43 UTC (rev 14218)
+++ branches/community/Seam_2_3/jboss-seam/src/main/resources/org/jboss/seam/blacklist.properties	2011-10-08 09:34:34 UTC (rev 14219)
@@ -1,4 +1,5 @@
-.getClass()
+.getClass(
+.class.
 .addRole(
 .getPassword(
 .removeRole(
\ No newline at end of file



More information about the seam-commits mailing list