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

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

Changeset: 27190455411103ab6a64fb13450075d17a471155
Author:    henrib <[email protected]>
Date:      2020-11-02 13:03
Message:   JEXL-336: changes, release notes

> Escape some control characters
> ------------------------------
>
>                 Key: JEXL-336
>                 URL: https://issues.apache.org/jira/browse/JEXL-336
>             Project: Commons JEXL
>          Issue Type: Bug
>            Reporter: Hussachai Puripunpinyo
>            Assignee: Henri Biestro
>            Priority: Major
>
> I found that JEXL doesn't honor the escape control characters such as \n, \t. 
> To reproduce this is simply evaluate this string "a\t\b" and it will yield 
> "a\t\b" instead of "a   b".
> The test code can explain this better. Note that I have to escape twice 
> because one is for Java and another one is for JEXL.
> {code:java}
> String[][] strings = new String[][] {
>     new String[] {"a\nb\tc", "'a\nb\tc'"}, // we still honor the actual 
> characters
>     new String[] {"a\nb\tc", "'a\\nb\\tc'"},
>     new String[] {"a\nb\tc", "\"a\\nb\\tc\""},
>     new String[] {"\b\t\n\f\r", "'\\b\\t\\n\\f\\r'"},
>     new String[] {"'hi'", "'\\'hi\\''"},
>     new String[] {"\"hi\"", "'\"hi\"'"},
>     new String[] {"\"hi\"", "'\"hi\"'"},
> };
> for(String[] pair: strings) {
>     String output = StringParser.buildString(pair[1], true);
>     Assert.assertEquals(pair[0], output);
> }{code}
> This change doesn't cover all control characters because it won't be used. I 
> follow the [ES5 JavaScript spec|http://es5.github.io/x7.html#x7.8.4] for the 
> control characters that it supports except \v which Java itself doesn't 
> support. I don't think it's being used that much anyway. Supporting \v is 
> tricky. We can represent it with the unicode value (\u000B) but JEXL is Java 
> and doing that in Java is not possible. Developers have to put the unicode in 
> the String anyway when it's used in the host language. That's why \v is not 
> included in the list. 



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

Reply via email to