Comments (7)
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.
确实是个bug,我关注下
from qlexpress.
script = StringEscapeUtils.unescapeJava(script);
通过org.apache.commons.lang.StringEscapeUtils反转义一下就好了
from qlexpress.
String script = "\"\\\".equals(\"4\");";
这个对应的 ql 代码是 "\".equals("4");
, 这个代码就算放在 java 里也是含有不封闭字符串的。ql 里的逻辑我认为没有问题
from qlexpress.
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.
这个问题可以解决么?
from qlexpress.
script = StringEscapeUtils.unescapeJava(script); 通过org.apache.commons.lang.StringEscapeUtils反转义一下就好了
反转义会把所有的\都去掉,如果想保留部分\就不行了
from qlexpress.
Related Issues (20)
- ExpressRunner 线程重入问题:计时器重置导致空指针
- QLExpress 3.3.2 黑白名单绕过 Blacklist and whitelist bypass HOT 1
- 升级3.3.1版本后,打了很多System.out.printl HOT 2
- 规则加载有没有加载同名配置的方法 HOT 2
- 设置"||"的别名为OR 的时候添加不成功提示已存在相同操作符,但是执行的时候又提示操作符不正确 HOT 2
- 升级3.3.2后if表达式条件判断有问题 HOT 2
- 想了解下4.0版本 HOT 2
- 转义字符被吞得问题 HOT 1
- Stack Overflow (ExpressRunner.loadMultiExpress) HOT 1
- Stack Overflow (ExpressParse.parse) HOT 1
- 自定义不定参数函数基本类型不支持 HOT 2
- 不能 return 空? HOT 1
- 能否支持直接输入已解析好的规则表达式,不用ql表达式自己的解析能力 HOT 1
- 3.2.0 异常时响应非常慢 HOT 5
- 代码注释编译异常 HOT 4
- new ExpressRunner() 导致内存泄漏 HOT 3
- QL是否支持链式函数
- 脚本执行过程中跳跃/漏执行 HOT 1
- 多线程并发的时候命中缓存场景 HOT 1
- 属性中存在属性名alias和关键词冲突了,能否识别xx.alias这种情况 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qlexpress.