Add SKIP_IDENTIFIER_CHECK system property to control checking of EL expressions
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 3 Aug 2010 16:16:15 +0000 (16:16 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 3 Aug 2010 16:16:15 +0000 (16:16 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@981951 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/el/util/Validation.java
webapps/docs/config/systemprops.xml

index b291fed..152dc2e 100644 (file)
@@ -17,6 +17,9 @@
 
 package org.apache.el.util;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
 public class Validation {
 
     // Java keywords, boolean literals & the null literal in alphabetical order
@@ -30,6 +33,30 @@ public class Validation {
         "throw", "throws", "transient", "true", "try", "void", "volatile",
         "while" };
     
+    private static final boolean IS_SECURITY_ENABLED =
+            (System.getSecurityManager() != null);
+
+    private static final boolean SKIP_IDENTIFIER_CHECK;
+
+    static {
+        if (IS_SECURITY_ENABLED) {
+            SKIP_IDENTIFIER_CHECK = AccessController.doPrivileged(
+                    new PrivilegedAction<Boolean>(){
+                        @Override
+                        public Boolean run() {
+                            return Boolean.valueOf(System.getProperty(
+                                    "org.apache.el.parser.SKIP_IDENTIFIER_CHECK",
+                            "false"));
+                        }
+                    }
+            ).booleanValue();
+        } else {
+            SKIP_IDENTIFIER_CHECK = Boolean.valueOf(System.getProperty(
+                    "org.apache.el.parser.SKIP_IDENTIFIER_CHECK",
+            "false")).booleanValue();
+        }
+    }
+    
     
     private Validation() {
         // Utility class. Hide default constructor
@@ -40,6 +67,10 @@ public class Validation {
      */
     public static boolean isIdentifier(String key) {
         
+        if (SKIP_IDENTIFIER_CHECK) {
+            return true;
+        }
+
         // Should not be the case but check to be sure
         if (key == null || key.length() == 0) {
             return false;
index 344720c..9e33abe 100644 (file)
       <code>true</code> will be used.</p>
     </property>
 
+    <property name="org.apache.el.parser.SKIP_IDENTIFIER_CHECK">
+      <p>If <code>true</code>, when parsing expressions, identifiers will not be
+      checked to ensure that they conform to the Java Language Specification for
+      Java identifiers. If not specified, the default value of
+      <code>false</code> will be used.</p>
+    </property>
+
   </properties>
 </section>