[jira] [Commented] (JEXL-336) Escape some control characters
[ https://issues.apache.org/jira/browse/JEXL-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17356985#comment-17356985 ] Hussachai Puripunpinyo commented on JEXL-336: - I'm not using JXLT and didn't know that it's broken. Sorry and thank you :) > 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] [Commented] (JEXL-336) Escape some control characters
[ https://issues.apache.org/jira/browse/JEXL-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17224831#comment-17224831 ] Hussachai Puripunpinyo commented on JEXL-336: - Thank you [~henrib]. > 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] [Commented] (JEXL-336) Escape some control characters
[ https://issues.apache.org/jira/browse/JEXL-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17224613#comment-17224613 ] Henri Biestro commented on JEXL-336: Thanks a lot for the bug and the PR; will resolve momentarily. > 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] [Commented] (JEXL-336) Escape some control characters
[ https://issues.apache.org/jira/browse/JEXL-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17224224#comment-17224224 ] Hussachai Puripunpinyo commented on JEXL-336: - The PR: https://github.com/apache/commons-jexl/pull/32 > 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 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 :) > -- This message was sent by Atlassian Jira (v8.3.4#803005)