commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Biestro (Jira)" <j...@apache.org>
Subject [jira] [Resolved] (JEXL-315) JxltEngine literal string strings ending in \ $ or # throw JxltEngine$Exception
Date Sun, 27 Oct 2019 13:02:00 GMT

     [ https://issues.apache.org/jira/browse/JEXL-315?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Henri Biestro resolved JEXL-315.
--------------------------------
    Resolution: Fixed

Changeset: c46fb0d5084c17b648088b36cfdf648f67328d5c
Author:    henrib <henrib@apache.org>
Date:      2019-10-27 13:37
Message:   JEXL-315: added handling of delimiters at end of lines

> JxltEngine literal string strings ending in \ $ or # throw JxltEngine$Exception
> -------------------------------------------------------------------------------
>
>                 Key: JEXL-315
>                 URL: https://issues.apache.org/jira/browse/JEXL-315
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 3.1
>            Reporter: Mike Bartlett
>            Assignee: Henri Biestro
>            Priority: Minor
>             Fix For: 3.2
>
>
> When parsing literal strings with the JxltEngine, if the string ends with \ $ or # a JxltEngine$Exception
is thrown. Escaping the ending character works, but seems an unnecessary burden on the user.
> Example:
> JxltEngine jxltEngine = (new JexlBuilder()).create().createJxltEngine();
>  Expression exp = jxltEngine.createExpression("Testing$");
>  Object value = exp.evaluate(new MapContext());
> Stack Trace:
> org.apache.commons.jexl3.JxltEngine$Exception: com.openmarket.workflow.el.ElEngineTest.testBug@40
failed to parse 'Testing$'org.apache.commons.jexl3.JxltEngine$Exception: com.openmarket.workflow.el.ElEngineTest.testBug@40
failed to parse 'Testing$' at org.apache.commons.jexl3.internal.TemplateEngine.createExpression(TemplateEngine.java:668)
at org.apache.commons.jexl3.JxltEngine.createExpression(JxltEngine.java:217) at com.openmarket.workflow.el.ElEngineTest.testBug(ElEngineTest.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at
java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463) at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)Caused
by: org.apache.commons.jexl3.JxltEngine$Exception: com.openmarket.workflow.el.ElEngineTest.testBug@40
malformed expression: Testing$ at org.apache.commons.jexl3.internal.TemplateEngine.parseExpression(TemplateEngine.java:886)
at org.apache.commons.jexl3.internal.TemplateEngine.createExpression(TemplateEngine.java:664)
... 25 more
>  
> Simple Fix in the code:
> org.apache.commons.jexl3.internal.TemplateEngine
> In method:
> {quote}{{TemplateExpression parseExpression(JexlInfo info, String expr, Scope scope)
{ // CSOFF: MethodLength}}
>  
> {{for (int column = 0; column < size; ++column) {}}
> {{  ...}}
> {{}}}
> {{// Add this code at the end of the for loop to h}}{{andle strings ending in \, # or
$}}
> {{ if (state == ParseState.ESCAPE) {}}
> {{    strb.append('\\');}}
> {{    state = ParseState.CONST;}}
> {{ } else if (state == ParseState.DEFERRED0) {}}
> {{    strb.append(deferredChar);}}
> {{    state = ParseState.CONST;}}
> {{ } else if (state == ParseState.IMMEDIATE0) {}}
> {{    strb.append(immediateChar);}}
> {{    state = ParseState.CONST;}}
> {{ }}}
> {{...}}
> {quote}
>  
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Mime
View raw message