Henri Biestro created JEXL-477:
----------------------------------

             Summary: Interpolation strings are parsed with the engine features 
instead of those of their script
                 Key: JEXL-477
                 URL: https://issues.apache.org/jira/browse/JEXL-477
             Project: Commons JEXL
          Issue Type: Bug
    Affects Versions: 3.7.1
            Reporter: Henri Biestro
            Assignee: Henri Biestro
             Fix For: 3.7.2



The expressions embedded in an interpolation string, or in an interpolated 
property name, are parsed with the features of the engine, not with those of 
the script that contains them. This only shows when a script is created with 
its own features through {{JexlEngine.createScript(JexlFeatures, JexlInfo, 
String, String...)}}.

With an engine that allows method calls and a script created with 
{{methodCall(false)}}:
{code}
s.length()          // Feature error, as expected
`${s.length()}`     // evaluates as 3, should be an error
s.`${s.length()}`   // parsed, should be an error
{code}

Conversely, with an engine created with {{methodCall(false)}} and a script 
whose features allow method calls, {{s.length()}} is accepted and the same call 
in an interpolation is rejected.

The same applies to antish variable names declared by the features of the 
script (JEXL-474): with {{x.y}} declared and defined in the context,
{code}
x.y        // 42
`${x.y}`   // fails, x.y is not solved as a variable
{code}

Fix: the parser hands its current features to the interpolation it creates, and 
cached interpolation expressions are keyed by those features. Scripts created 
with the features of the engine are not affected.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to