You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/11/05 23:51:30 UTC
svn commit: r1539176 - in /tomcat/tc7.0.x/trunk: ./
java/org/apache/jasper/compiler/ELParser.java
test/org/apache/jasper/compiler/TestELParser.java
Author: markt
Date: Tue Nov 5 22:51:30 2013
New Revision: 1539176
URL: http://svn.apache.org/r1539176
Log:
Fix various bugs in Jasper's simplified EL parser and add the test case that found them.
This is a precursor to fixing BZ55198 / BZ55735 since that is going to require separating an attribute value into EL and non-EL components
Added:
tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestELParser.java
- copied unchanged from r1539157, tomcat/trunk/test/org/apache/jasper/compiler/TestELParser.java
Modified:
tomcat/tc7.0.x/trunk/ (props changed)
tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/ELParser.java
Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
Merged /tomcat/trunk:r1539157
Modified: tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/ELParser.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/ELParser.java?rev=1539176&r1=1539175&r2=1539176&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/ELParser.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/ELParser.java Tue Nov 5 22:51:30 2013
@@ -17,6 +17,12 @@
package org.apache.jasper.compiler;
+import org.apache.jasper.JasperException;
+import org.apache.jasper.compiler.ELNode.ELText;
+import org.apache.jasper.compiler.ELNode.Function;
+import org.apache.jasper.compiler.ELNode.Root;
+import org.apache.jasper.compiler.ELNode.Text;
+
/**
* This class implements a parser for EL expressions.
*
@@ -108,6 +114,7 @@ public class ELParser {
// Output whatever is in buffer
if (buf.length() > 0) {
ELexpr.add(new ELNode.ELText(buf.toString()));
+ buf = new StringBuilder();
}
if (!parseFunction()) {
ELexpr.add(new ELNode.ELText(curToken.toString()));
@@ -133,8 +140,8 @@ public class ELParser {
}
String s1 = null; // Function prefix
String s2 = curToken.toString(); // Function name
- int mark = getIndex();
if (hasNext()) {
+ int mark = getIndex();
curToken = nextToken();
if (curToken.toChar() == ':') {
if (hasNext()) {
@@ -152,8 +159,9 @@ public class ELParser {
ELexpr.add(new ELNode.Function(s1, s2));
return true;
}
+ curToken = prevToken;
+ setIndex(mark);
}
- setIndex(mark);
return false;
}
@@ -398,4 +406,42 @@ public class ELParser {
public char getType() {
return type;
}
+
+
+ protected static class TextBuilder extends ELNode.Visitor {
+
+ protected StringBuilder output = new StringBuilder();
+
+ public String getText() {
+ return output.toString();
+ }
+
+ @Override
+ public void visit(Root n) throws JasperException {
+ output.append(n.getType());
+ output.append('{');
+ n.getExpression().visit(this);
+ output.append('}');
+ }
+
+ @Override
+ public void visit(Function n) throws JasperException {
+ if (n.getPrefix() != null) {
+ output.append(n.getPrefix());
+ output.append(':');
+ }
+ output.append(n.getName());
+ output.append('(');
+ }
+
+ @Override
+ public void visit(Text n) throws JasperException {
+ output.append(n.getText());
+ }
+
+ @Override
+ public void visit(ELText n) throws JasperException {
+ output.append(n.getText());
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org