Vincent Bussol created JEXL-455:
-----------------------------------

             Summary: tokenization error with multiline expressions
                 Key: JEXL-455
                 URL: https://issues.apache.org/jira/browse/JEXL-455
             Project: Commons JEXL
          Issue Type: Bug
    Affects Versions: 3.6.1
            Reporter: Vincent Bussol


Since [JEXL-441|https://issues.apache.org/jira/browse/JEXL-441], the same 
tokenization error occurs with multiline expressions. Our users have the 
ability to create various types of templates (html, scripts). For example:

 
{code:java}
<ul>
  <li>Coffee</li>
  <li>
    <b>
      ${relation('Market_Product')
        .fetch(CONTINENT.current(), Product.current())
        .field['LocalDescription']}
    </b>
  </li>
  <li>Milk</li>
</ul> {code}
The template creation is in error:
{code:java}
tokenization error in '' {code}
This was not the case before. I'm sure this wasn't expected behavior and can be 
considered a bug exploit. However, existing (stored) templates (and scripts) 
may be in error.

Some tests:
{code:java}
@Test
void testIssue441b() {
    final JexlEngine jexl = new JexlBuilder().create();
    final JexlContext context = new MapContext();
    context.set("name", "Hello");
    final String code = "return `${name\n+ name}`;";
    final JexlScript script = jexl.createScript(code);
    Object o = script.execute(context);
    assertEquals("HelloHello", o);
}

@Test
void testIssue441c() {
    final JexlEngine jexl = new JexlBuilder().create();
    final JexlContext context = new MapContext();
    context.set("name", "Hello");
    final JxltEngine jxlt = jexl.createJxltEngine();
    final JxltEngine.Template template = 
jxlt.createTemplate("<b>\n\t${name\n\t+ name}\n</b>");
    final StringWriter writer = new StringWriter();
    template.evaluate(context, writer);
    assertEquals("<b>\n\tHelloHello\n</b>", writer.toString());
} {code}
 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to