You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ki...@apache.org on 2003/11/25 02:38:21 UTC

cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler ELParser.java

kinman      2003/11/24 17:38:21

  Modified:    jasper2/src/share/org/apache/jasper/compiler ELParser.java
  Log:
  - Fix 24957: Operators are mis-treated as functions
  
  Revision  Changes    Path
  1.3       +27 -1     jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ELParser.java
  
  Index: ELParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ELParser.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ELParser.java	30 Oct 2003 02:39:48 -0000	1.2
  +++ ELParser.java	25 Nov 2003 01:38:21 -0000	1.3
  @@ -77,6 +77,11 @@
       private String expression;	// The EL expression
       private boolean escapeBS;	// is '\' an escape char in text outside EL?
   
  +    private static final String reservedWords[] = {
  +        "and", "div", "empty", "eq", "false",
  +        "ge", "gt", "instanceof", "le", "lt", "mod",
  +        "ne", "not", "null", "or", "true"};
  +
       public ELParser(String expression) {
   	index = 0;
   	this.expression = expression;
  @@ -145,7 +150,7 @@
        * Note: currently we don't parse arguments
        */
       private boolean parseFunction() {
  -	if (! (curToken instanceof Id)) {
  +	if (! (curToken instanceof Id) || isELReserved(curToken.toString())) {
   	    return false;
   	}
   	String s1 = null;                 // Function prefix
  @@ -172,6 +177,27 @@
   	}
   	setIndex(mark);
   	return false;
  +    }
  +
  +    /**
  +     * Test if an id is a reserved word in EL
  +     */
  +    private boolean isELReserved(String id) {
  +        int i = 0;
  +        int j = reservedWords.length;
  +        while (i < j) {
  +            int k = (i+j)/2;
  +            int result = reservedWords[k].compareTo(id);
  +            if (result == 0) {
  +                return true;
  +            }
  +            if (result < 0) {
  +                i = k+1;
  +            } else {
  +                j = k;
  +            }
  +        }
  +        return false;
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org