Skip to content

Commit

Permalink
Fix an edge case parser bug found while investigating BZ 57136
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1702092 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
markt-asf committed Sep 9, 2015
1 parent 0d40741 commit 7bd0e35
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion java/org/apache/el/parser/ELParser.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ java.util.Deque<Integer> deque = new java.util.ArrayDeque<Integer>();
*/
< LITERAL_EXPRESSION:
( (~["$", "#", "\\"])* "\\" (["$", "#"])?
| (~["$", "#"])* (["$", "#"] ~["{", "$", "#"])
| (~["$", "#"])* (["$", "#"] ~["{", "$", "#", "\\"])
| (~["$", "#"])+
)+
| "$"
Expand Down
4 changes: 1 addition & 3 deletions java/org/apache/el/parser/ELParserTokenManager.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* Generated By:JJTree&JavaCC: Do not edit this line. ELParserTokenManager.java */
package org.apache.el.parser;
import java.io.StringReader;
import javax.el.ELException;

/** Token Manager. */
@SuppressWarnings("all") // Ignore warnings in generated code
Expand Down Expand Up @@ -187,7 +185,7 @@ else if (curChar == 92)
jjCheckNAddTwoStates(3, 4);
break;
case 5:
if ((0xf7ffffffffffffffL & l) == 0L)
if ((0xf7ffffffefffffffL & l) == 0L)
break;
if (kind > 1)
kind = 1;
Expand Down
27 changes: 27 additions & 0 deletions test/org/apache/el/TestELEvaluation.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.junit.Assert;
import org.junit.Test;

import org.apache.el.lang.ELSupport;
Expand Down Expand Up @@ -207,6 +208,32 @@ public void testMixedTypes() {
assertNotNull(e);
}

@Test
public void testEscape01() {
Assert.assertEquals("$${", evaluateExpression("$\\${"));
}

@Test
public void testBug49081a() {
Assert.assertEquals("$2", evaluateExpression("$${1+1}"));
}

@Test
public void testBug49081b() {
Assert.assertEquals("#2", evaluateExpression("##{1+1}"));
}

@Test
public void testBug49081c() {
Assert.assertEquals("#2", evaluateExpression("#${1+1}"));
}

@Test
public void testBug49081d() {
Assert.assertEquals("$2", evaluateExpression("$#{1+1}"));
}


// ************************************************************************

private String evaluateExpression(String expression) {
Expand Down

0 comments on commit 7bd0e35

Please sign in to comment.