You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2004/10/21 02:35:25 UTC

DO NOT REPLY [Bug 31816] New: - Certain EL statements cause an apparant infinite loop in the EL parser.

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31816>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31816

Certain EL statements cause an apparant infinite loop in the EL parser.

           Summary: Certain EL statements cause an apparant infinite loop in
                    the EL parser.
           Product: Commons
           Version: 1.0 Final
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: Critical
          Priority: Other
         Component: EL
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: blenkush@ccs.neu.edu
                CC: blenkush@ccs.neu.edu


The following EL statement causes an apparant infinite loop in the EL parser:

${(fn:toUpperCase(fn:toUpperCase(fn:toUpperCase(fn:toUpperCase(fn:toUpperCase(fn:toUpperCase(fn:
toUpperCase(fn:toUpperCase(fn:toUpperCase(fn:toUpperCase(fn:toUpperCase(fn:toUpperCase(fn:
toUpperCase(fn:toUpperCase(fn:toUpperCase(fn:toUpperCase(fn:toUpperCase(fn:toUpperCase(fn:
toUpperCase(fn:toUpperCase(fn:toUpperCase(fn:toUpperCase(fn:toUpperCase(fn:toUpperCase(fn:
toUpperCase(fn:toUpperCase(fn:toUpperCase(fn:toUpperCase(fn:toUpperCase(fn:toUpperCase(fn:
toUpperCase(fn:toUpperCase('b')))))))))))))))))))))))))))))))))}

This is due to the LOOKAHEAD on line 256 of ELParser.jj

I have an initial fix which allows the EL expression to be parsed quickly but I have not tested 
thoroughly. In ELParser.jj delete the grammar production ConditionalExpression() and replace 
Expression() and OrExpression() with the below text: 

Expression Expression () :
{
  Expression ret;
}
{
  (
   ret = OrExpression ()
  )
  { return ret; }
}


Expression OrExpression () :
{
  Expression startExpression, condition, trueBranch=null, falseBranch=null;
  BinaryOperator operator;
  Expression expression;
  List operators = null;
  List expressions = null;
}
{
  startExpression = AndExpression ()

    ((
     (
      (<OR1> | <OR2>) { operator = OrOperator.SINGLETON; }
      )
     expression = AndExpression ()

      {
	if (operators == null) {
	  operators = new ArrayList ();
	  expressions = new ArrayList ();
	}
	operators.add (operator);
	expressions.add (expression);
      }
     )*
     (
     <COND>
     trueBranch = Expression ()
     <COLON>
     falseBranch = Expression ()
     )?
    )
  {
    if (operators != null) {
      condition = new BinaryOperatorExpression (startExpression,
					   operators,
					   expressions);
    }
    else {
      condition = startExpression;
    }
    
    if(trueBranch != null)
        return new ConditionalExpression(condition, trueBranch, falseBranch);
    else
        return condition;
  }
}

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