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

Henri Biestro resolved JEXL-98.
-------------------------------

       Resolution: Fixed
    Fix Version/s: 2.0.1

922023  Thu Mar 11 22:13:34 CET 2010    henrib
Parser.jjt modified to allow proper escaping (backslash);
Added test for JEXL-98 & JEXL-97;
Added a formatting space in JexlException
Issue #JEXL-98 - Quote escaping cannot be escaped

trunk/src/test/java/org/apache/commons/jexl2/IssuesTest.java 
trunk/src/main/java/org/apache/commons/jexl2/parser/Parser.jjt 
trunk/src/main/java/org/apache/commons/jexl2/JexlException.java
Committed revision 922023.

> Quote escaping cannot be escaped
> --------------------------------
>
>                 Key: JEXL-98
>                 URL: https://issues.apache.org/jira/browse/JEXL-98
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 2.0
>         Environment: All Java
>            Reporter: Marcel Schoen
>            Assignee: Henri Biestro
>            Priority: Minor
>             Fix For: 2.0.1
>
>
> I want to invoke a "replace" method which (pretty much like String.replace()) 
> takes three String parameters:
> function.replace(String text, String oldPart, String newPart)
> If I invoke it to replace single backslash characters with double backslash 
> characters (which is admittedly a VERY special use case), I invoke it in my 
> unit test with an expression like this one:
>   function.replace('DOMAIN\somename', '\\', '\\\\')
> The result with JEXL 1.x was a string "DOMAIN\\somename". But with JEXL 2, I 
> get this error:
> 2010-03-11 14:50:59,681 [CC:] [RC:] [CN:] - [SYSTEM] [INVALID_EXPR] Invalid 
> expression in configuration. Expression: 'function.replace('DOMAIN\myname', 
> '\\', '\\\\') / Exception: org.apache.commons.jexl2.JexlException: 
> com.usp.sls.toolkit.expression.impl.jexl2provider.getscr...@441tokenization 
> failed'
> org.apache.commons.jexl2.JexlException: 
> com.usp.sls.toolkit.expression.impl.jexl2provider.getscr...@441tokenization 
> failed
>       at org.apache.commons.jexl2.JexlEngine.parse(JexlEngine.java:816)
>       at org.apache.commons.jexl2.JexlEngine.createScript(JexlEngine.java:414)
>       at org.apache.commons.jexl2.JexlEngine.createScript(JexlEngine.java:397)
>       at 
> com.usp.sls.toolkit.expression.impl.Jexl2Provider.getScript(Jexl2Provider.java:441)
>       at 
> com.usp.sls.toolkit.expression.impl.Jexl2Provider.evaluateExpression(Jexl2Provider.java:152)
>       at 
> com.usp.sls.toolkit.expression.Expression.evaluateExpression(Expression.java:201)
>       at com.usp.sls.toolkit.expression.JexlTest.testReplace(JexlTest.java:84)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:597)
>       at junit.framework.TestCase.runTest(TestCase.java:164)
>       at junit.framework.TestCase.runBare(TestCase.java:130)
>       at junit.framework.TestResult$1.protect(TestResult.java:110)
>       at junit.framework.TestResult.runProtected(TestResult.java:128)
>       at junit.framework.TestResult.run(TestResult.java:113)
>       at junit.framework.TestCase.run(TestCase.java:120)
>       at junit.framework.TestSuite.runTest(TestSuite.java:228)
>       at junit.framework.TestSuite.run(TestSuite.java:223)
>       at 
> org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
>       at 
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
>       at 
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
> Caused by: org.apache.commons.jexl2.parser.TokenMgrError: Lexical error at 
> line 1, column 42.  Encountered: "\\" (92), after : ""
>       at 
> org.apache.commons.jexl2.parser.ParserTokenManager.getNextToken(ParserTokenManager.java:1564)
>       at 
> org.apache.commons.jexl2.parser.Parser.jj_scan_token(Parser.java:3914)
>       at org.apache.commons.jexl2.parser.Parser.jj_3R_118(Parser.java:2776)
>       at org.apache.commons.jexl2.parser.Parser.jj_3R_111(Parser.java:2759)
> Obviously, the JEXL parser thinks that the backslash in the first string is 
> meant to escape the following quote, which it isn't. The String should 
> actually end there. So, I tried to escape the escape character, like this:
>   function.replace('DOMAIN\somename', '\\\\', '\\\\\\\\')
> But to no avail, same error.
> So, can escape characters be escaped in JEXL 2?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to