-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CVE-2021-28170 Fix expression delimiter escaping
Co-authored-by: rmartinc rmartinc@redhat.com
- Loading branch information
1 parent
2a2fa59
commit b6a3943
Showing
3 changed files
with
58 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package org.glassfish.el.test; | ||
|
||
import jakarta.el.ELManager; | ||
import jakarta.el.ELProcessor; | ||
import jakarta.el.ValueExpression; | ||
import org.junit.Assert; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class EscapingTest { | ||
|
||
static ELProcessor elp; | ||
static ELManager elm; | ||
|
||
public EscapingTest() { | ||
} | ||
|
||
@BeforeClass | ||
public static void setUpClass() throws Exception { | ||
elp = new ELProcessor(); | ||
elm = elp.getELManager(); | ||
} | ||
|
||
@Test | ||
public void testEscape01() { | ||
assertEquals("$2", evaluateExpression("$${1+1}")); | ||
assertEquals("$${1+1}", evaluateExpression("$\\${1+1}")); | ||
} | ||
|
||
@Test | ||
public void testEscape02() { | ||
assertEquals("$2", evaluateExpression("$#{1+1}")); | ||
assertEquals("$#{1+1}", evaluateExpression("$\\#{1+1}")); | ||
} | ||
|
||
@Test | ||
public void testEscape03() { | ||
assertEquals("#2", evaluateExpression("##{1+1}")); | ||
assertEquals("##{1+1}", evaluateExpression("#\\#{1+1}")); | ||
} | ||
|
||
@Test | ||
public void testEscape04() { | ||
assertEquals("#2", evaluateExpression("#${1+1}")); | ||
assertEquals("#${1+1}", evaluateExpression("#\\${1+1}")); | ||
} | ||
|
||
private String evaluateExpression(String expr) { | ||
ValueExpression v = ELManager.getExpressionFactory().createValueExpression( | ||
elm.getELContext(), expr, String.class); | ||
return (String) v.getValue(elm.getELContext()); | ||
} | ||
} |