Coder Social home page Coder Social logo

发现一个bug about qlexpress HOT 7 CLOSED

alibaba avatar alibaba commented on May 3, 2024
发现一个bug

from qlexpress.

Comments (7)

w1014804721 avatar w1014804721 commented on May 3, 2024

ExpressRunner runner = new ExpressRunner();
IExpressContext<String, Object> context = new DefaultContext<String, Object>();
String script = "\"\\\".equals(\"4\");";
Object result = runner.execute(script, context, null, true, false);
System.out.println(result);
这一段代码会报字符串没有关闭的错误,原因是在解析表达式的时候,对反斜杠的处理有误。
com.ql.util.express.parse.WordSplit中的parse方法,在找到一个引号的时候,需要找到与之配对的另一个引号,找到另一个引号之后,会判断前面是否是反斜杠,如果是反斜杠,就认为该引号被转义。这个地方应该是个bug,因为引号前面的反斜杠不一定是转义引号用的,应当改成判断该引号前面有多少个反斜杠,如果是偶数个,就说明这个引号就是结束引号,如果是奇数个,就说明是转义的引号。

from qlexpress.

baoxingjie avatar baoxingjie commented on May 3, 2024

确实是个bug,我关注下

from qlexpress.

lovejiegirl avatar lovejiegirl commented on May 3, 2024

script = StringEscapeUtils.unescapeJava(script);
通过org.apache.commons.lang.StringEscapeUtils反转义一下就好了

from qlexpress.

DQinYuan avatar DQinYuan commented on May 3, 2024

String script = "\"\\\".equals(\"4\");"; 这个对应的 ql 代码是 "\".equals("4");, 这个代码就算放在 java 里也是含有不封闭字符串的。ql 里的逻辑我认为没有问题

from qlexpress.

w1014804721 avatar w1014804721 commented on May 3, 2024

String script = "\"\\\".equals(\"4\");"; 这个对应的 ql 代码是 "\".equals("4");, 这个代码就算放在 java 里也是含有不封闭字符串的。ql 里的逻辑我认为没有问题

String script = ""\\".equals("4");"; 这样也是一样的,对应的ql代码是"\".equals("4"),
代码如下:
String script = ""\\".equals("4");";
System.out.println(script);
System.out.println("\".equals("4"));
ExpressRunner runner = new ExpressRunner();
IExpressContext<String, Object> context = new DefaultContext<String, Object>();
Object result = runner.execute(script, context, null, true, false);
System.out.println(result);
抛异常Exception in thread "main" java.lang.Exception: 字符串没有关闭

from qlexpress.

wenzhuozou avatar wenzhuozou commented on May 3, 2024

这个问题可以解决么?

from qlexpress.

wenzhuozou avatar wenzhuozou commented on May 3, 2024

script = StringEscapeUtils.unescapeJava(script); 通过org.apache.commons.lang.StringEscapeUtils反转义一下就好了

反转义会把所有的\都去掉,如果想保留部分\就不行了

from qlexpress.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.