[jira] [Updated] (JEXL-336) Escape some control characters

2021-06-03 Thread Henri Biestro (Jira)


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

Henri Biestro updated JEXL-336:
---
Fix Version/s: 3.2

> 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
> Fix For: 3.2
>
>
> 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)


[jira] [Updated] (JEXL-336) Escape some control characters

2020-11-02 Thread Henri Biestro (Jira)


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

Henri Biestro updated JEXL-336:
---
Assignee: Henri Biestro

> 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)


[jira] [Updated] (JEXL-336) Escape some control characters

2020-10-31 Thread Hussachai Puripunpinyo (Jira)


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

Hussachai Puripunpinyo updated JEXL-336:

Description: 
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. 

  was:
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.

I'm currently using the fork version of JEXL at my company since a lot of 
things cannot be made without modifying the JEXL code. I'd like to push some of 
my changes back to the upstream because I think it's useful to others and it 
will make my life easier when I have to merge the upstream to my fork. There 
will be more coming if the first one goes well :) 

 


> 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
>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